mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
docs(book): start book chapter for network crate (#445)
* WIP FOR DRAFT PR * WIP draft, walking through usage in pipeline * diving deeper into instantiation of NetworkHandle & FetchClient * WIP network management task & eth requests task done (ish) * address pr comments: networkmanager as standalone task, networkconfig as main entrypoint for setup * complete draft of the crate docs * restructured, starts w/ expl of * added more snippets/anchors * using ignore flag on code blocks, brief explanation of struct * typos addressed
This commit is contained in:
@ -105,6 +105,7 @@ impl Command {
|
||||
let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?;
|
||||
|
||||
info!("Connecting to p2p");
|
||||
// ANCHOR: snippet-execute
|
||||
let network = start_network(network_config(db.clone(), chain_id, genesis_hash)).await?;
|
||||
|
||||
// TODO: Are most of these Arcs unnecessary? For example, fetch client is completely
|
||||
@ -154,6 +155,7 @@ impl Command {
|
||||
// Run pipeline
|
||||
info!("Starting pipeline");
|
||||
pipeline.run(db.clone()).await?;
|
||||
// ANCHOR_END: snippet-execute
|
||||
|
||||
info!("Finishing up");
|
||||
Ok(())
|
||||
@ -222,6 +224,7 @@ fn network_config<DB: Database>(
|
||||
}
|
||||
|
||||
/// Starts the networking stack given a [NetworkConfig] and returns a handle to the network.
|
||||
// ANCHOR: fn-start_network
|
||||
async fn start_network<C>(config: NetworkConfig<C>) -> Result<NetworkHandle, NetworkError>
|
||||
where
|
||||
C: BlockProvider + HeaderProvider + 'static,
|
||||
@ -235,3 +238,4 @@ where
|
||||
tokio::task::spawn(eth);
|
||||
Ok(handle)
|
||||
}
|
||||
// ANCHOR_END: fn-start_network
|
||||
|
||||
Reference in New Issue
Block a user