feat(network): implement split read / write for NamedPipe bearer (#371)
This commit is contained in:
parent
57d84fe1e9
commit
1e7407867f
3 changed files with 90 additions and 43 deletions
|
|
@ -1,11 +1,11 @@
|
|||
use pallas::{
|
||||
ledger::addresses::Address,
|
||||
ledger::{addresses::Address, traverse::MultiEraBlock},
|
||||
network::{
|
||||
facades::NodeClient,
|
||||
miniprotocols::{
|
||||
chainsync,
|
||||
localstate::queries_v16::{self, Addr, Addrs},
|
||||
Point, PRE_PRODUCTION_MAGIC,
|
||||
Point, PRE_PRODUCTION_MAGIC, PREVIEW_MAGIC
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -66,15 +66,15 @@ async fn do_chainsync(client: &mut NodeClient) {
|
|||
|
||||
info!("intersected point is {:?}", point);
|
||||
|
||||
for _ in 0..10 {
|
||||
loop {
|
||||
let next = client.chainsync().request_next().await.unwrap();
|
||||
|
||||
match next {
|
||||
chainsync::NextResponse::RollForward(h, _) => {
|
||||
log::info!("rolling forward, block size: {}", h.len())
|
||||
let block_number = MultiEraBlock::decode(&h).unwrap().number();
|
||||
info!("rolling forward {}, block size: {}", block_number, h.len())
|
||||
}
|
||||
chainsync::NextResponse::RollBackward(x, _) => log::info!("rollback to {:?}", x),
|
||||
chainsync::NextResponse::Await => log::info!("tip of chain reached"),
|
||||
chainsync::NextResponse::RollBackward(x, _) => info!("rollback to {:?}", x),
|
||||
chainsync::NextResponse::Await => info!("tip of chain reached"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -82,6 +82,7 @@ async fn do_chainsync(client: &mut NodeClient) {
|
|||
// change the following to match the Cardano node socket in your local
|
||||
// environment
|
||||
const SOCKET_PATH: &str = "/tmp/node.socket";
|
||||
const PIPE_NAME: &str = "\\\\.\\pipe\\cardano-pallas";
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::main]
|
||||
|
|
@ -106,7 +107,26 @@ async fn main() {
|
|||
do_chainsync(&mut client).await;
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "unix"))]
|
||||
fn main() {
|
||||
panic!("can't use n2c unix socket on non-unix systems");
|
||||
#[cfg(target_family = "windows")]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
||||
tracing::subscriber::set_global_default(
|
||||
tracing_subscriber::FmtSubscriber::builder()
|
||||
.with_max_level(tracing::Level::TRACE)
|
||||
.finish(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// we connect to the namedpipe of the local node. Make sure you have the right
|
||||
// path for your environment
|
||||
let mut client = NodeClient::connect(PIPE_NAME, PREVIEW_MAGIC)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// execute an arbitrary "Local State" query against the node
|
||||
do_localstate_query(&mut client).await;
|
||||
|
||||
// execute the chainsync flow from an arbitrary point in the chain
|
||||
do_chainsync(&mut client).await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue