mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: improve beacon api example (#9660)
This commit is contained in:
@ -28,7 +28,7 @@ pub mod mined_sidecar;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Cli::<BeaconSidecarConfig>::parse()
|
Cli::<BeaconSidecarConfig>::parse()
|
||||||
.run(|builder, args| async move {
|
.run(|builder, beacon_config| async move {
|
||||||
// launch the node
|
// launch the node
|
||||||
let NodeHandle { node, node_exit_future } =
|
let NodeHandle { node, node_exit_future } =
|
||||||
builder.node(EthereumNode::default()).launch().await?;
|
builder.node(EthereumNode::default()).launch().await?;
|
||||||
@ -38,27 +38,30 @@ fn main() {
|
|||||||
|
|
||||||
let pool = node.pool.clone();
|
let pool = node.pool.clone();
|
||||||
|
|
||||||
let mut sidecar_stream = MinedSidecarStream {
|
node.task_executor.spawn(async move {
|
||||||
events: notifications,
|
let mut sidecar_stream = MinedSidecarStream {
|
||||||
pool,
|
events: notifications,
|
||||||
beacon_config: args,
|
pool,
|
||||||
client: reqwest::Client::new(),
|
beacon_config,
|
||||||
pending_requests: FuturesUnordered::new(),
|
client: reqwest::Client::new(),
|
||||||
queued_actions: VecDeque::new(),
|
pending_requests: FuturesUnordered::new(),
|
||||||
};
|
queued_actions: VecDeque::new(),
|
||||||
|
};
|
||||||
|
|
||||||
while let Some(result) = sidecar_stream.next().await {
|
while let Some(result) = sidecar_stream.next().await {
|
||||||
match result {
|
match result {
|
||||||
Ok(blob_transaction) => {
|
Ok(blob_transaction) => {
|
||||||
// Handle successful transaction
|
// Handle successful transaction
|
||||||
println!("Processed BlobTransaction: {:?}", blob_transaction);
|
println!("Processed BlobTransaction: {:?}", blob_transaction);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Handle errors specifically
|
// Handle errors specifically
|
||||||
eprintln!("Failed to process transaction: {:?}", e);
|
eprintln!("Failed to process transaction: {:?}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
node_exit_future.await
|
node_exit_future.await
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user