mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(network): added NetworkConfigBuilder.block_import(..) (#5783)
Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
This commit is contained in:
@ -169,6 +169,9 @@ pub struct NetworkConfigBuilder {
|
||||
head: Option<Head>,
|
||||
/// Whether tx gossip is disabled
|
||||
tx_gossip_disabled: bool,
|
||||
/// The block importer type
|
||||
#[serde(skip)]
|
||||
block_import: Option<Box<dyn BlockImport>>,
|
||||
/// Optimism Network Config Builder
|
||||
#[cfg(feature = "optimism")]
|
||||
optimism_network_config: OptimismNetworkConfigBuilder,
|
||||
@ -204,6 +207,7 @@ impl NetworkConfigBuilder {
|
||||
extra_protocols: Default::default(),
|
||||
head: None,
|
||||
tx_gossip_disabled: false,
|
||||
block_import: None,
|
||||
#[cfg(feature = "optimism")]
|
||||
optimism_network_config: OptimismNetworkConfigBuilder::default(),
|
||||
}
|
||||
@ -396,6 +400,12 @@ impl NetworkConfigBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the block import type.
|
||||
pub fn block_import(mut self, block_import: Box<dyn BlockImport>) -> Self {
|
||||
self.block_import = Some(block_import);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the sequencer HTTP endpoint.
|
||||
#[cfg(feature = "optimism")]
|
||||
pub fn sequencer_endpoint(mut self, endpoint: Option<String>) -> Self {
|
||||
@ -427,6 +437,7 @@ impl NetworkConfigBuilder {
|
||||
extra_protocols,
|
||||
head,
|
||||
tx_gossip_disabled,
|
||||
block_import,
|
||||
#[cfg(feature = "optimism")]
|
||||
optimism_network_config: OptimismNetworkConfigBuilder { sequencer_endpoint },
|
||||
} = self;
|
||||
@ -473,7 +484,7 @@ impl NetworkConfigBuilder {
|
||||
peers_config: peers_config.unwrap_or_default(),
|
||||
sessions_config: sessions_config.unwrap_or_default(),
|
||||
chain_spec,
|
||||
block_import: Box::<ProofOfStakeBlockImport>::default(),
|
||||
block_import: block_import.unwrap_or(Box::<ProofOfStakeBlockImport>::default()),
|
||||
network_mode,
|
||||
executor: executor.unwrap_or_else(|| Box::<TokioTaskExecutor>::default()),
|
||||
status,
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
//! This module provides an abstraction over block import in the form of the `BlockImport` trait.
|
||||
|
||||
use crate::message::NewBlockMessage;
|
||||
use reth_primitives::PeerId;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
@ -122,10 +122,10 @@ pub mod error;
|
||||
pub mod eth_requests;
|
||||
mod fetch;
|
||||
mod flattened_response;
|
||||
mod import;
|
||||
pub mod import;
|
||||
mod listener;
|
||||
mod manager;
|
||||
mod message;
|
||||
pub mod message;
|
||||
mod metrics;
|
||||
mod network;
|
||||
pub mod peers;
|
||||
|
||||
@ -158,11 +158,17 @@ impl PeerRequest {
|
||||
|
||||
/// Corresponding variant for [`PeerRequest`].
|
||||
#[derive(Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum PeerResponse {
|
||||
/// Response to a [`GetBlockHeaders`] request.
|
||||
BlockHeaders { response: oneshot::Receiver<RequestResult<BlockHeaders>> },
|
||||
/// Response to a [`GetBlockBodies`] request.
|
||||
BlockBodies { response: oneshot::Receiver<RequestResult<BlockBodies>> },
|
||||
/// Response to a [`GetPooledTransactions`] request.
|
||||
PooledTransactions { response: oneshot::Receiver<RequestResult<PooledTransactions>> },
|
||||
/// Response to a [`GetNodeData`] request.
|
||||
NodeData { response: oneshot::Receiver<RequestResult<NodeData>> },
|
||||
/// Response to a [`GetReceipts`] request.
|
||||
Receipts { response: oneshot::Receiver<RequestResult<Receipts>> },
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user