pub fn new(
        config: &ZebradConfig,
        peers: ZN,
        verifier: ZV,
        state: ZS,
        latest_chain_tip: LatestChainTip,
    ) -> (Self, SyncStatus) {
        let tip_network = Timeout::new(peers.clone(), TIPS_RESPONSE_TIMEOUT);
        // The Hedge middleware is the outermost layer, hedging requests
        // between two retry-wrapped networks.  The innermost timeout
        // layer is relatively unimportant, because slow requests will
        // probably be pre-emptively hedged.
        //
        // The Hedge goes outside the Retry, because the Retry layer
        // abstracts away spurious failures from individual peers
        // making a less-fallible network service, and the Hedge layer
        // tries to reduce latency of that less-fallible service.
        //
        // XXX add ServiceBuilder::hedge() so this becomes
        // ServiceBuilder::new().hedge(...).retry(...)...
        let block_network = Hedge::new(
            ServiceBuilder::new()
                .concurrency_limit(config.sync.max_concurrent_block_requests)
                .retry(zn::RetryLimit::new(BLOCK_DOWNLOAD_RETRY_LIMIT))
                .timeout(BLOCK_DOWNLOAD_TIMEOUT)
                .service(peers),
            AlwaysHedge,
            20,
            0.95,
            2 * SYNC_RESTART_DELAY,
        );

        // We apply a timeout to the verifier to avoid hangs due to missing earlier blocks.
        let verifier = Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT);

        assert!(
            config.sync.lookahead_limit >= MIN_LOOKAHEAD_LIMIT,
            "configured lookahead limit {} too low, must be at least {}",
            config.sync.lookahead_limit,
            MIN_LOOKAHEAD_LIMIT
        );

        let (sync_status, recent_syncs) = SyncStatus::new();

        let new_syncer = Self {
            genesis_hash: genesis_hash(config.network.network),
            lookahead_limit: config.sync.lookahead_limit,
            tip_network,
            downloads: Box::pin(Downloads::new(
                block_network,
                verifier,
                latest_chain_tip,
                config.sync.lookahead_limit,
            )),
            state,
            prospective_tips: HashSet::new(),
            recent_syncs,
        };

        (new_syncer, sync_status)
    }
/// Returns a new syncer instance, using:
///  - chain: the zebra-chain `Network` to download (Mainnet or Testnet)
///  - peers: the zebra-network peers to contact for downloads
///  - verifier: the zebra-consensus verifier that checks the chain
///  - state: the zebra-state that stores the chain
///  - latest_chain_tip: the latest chain tip from `state`
///
/// Also returns a [`SyncStatus`] to check if the syncer has likely reached the chain tip.


Also returns a [`SyncStatus`] to check if the syncer has likely reached the chain tip.
Also returns a [ ` SyncStatus ` ] to check if the syncer has likely reached the chain tip .
pub fn new(
        config: &ZebradConfig,
        peers: ZN,
        verifier: ZV,
        state: ZS,
        latest_chain_tip: LatestChainTip,
    ) -> (Self, SyncStatus) {
        let tip_network = Timeout::new(peers.clone(), TIPS_RESPONSE_TIMEOUT);
        // The Hedge middleware is the outermost layer, hedging requests
        // between two retry-wrapped networks.  The innermost timeout
        // layer is relatively unimportant, because slow requests will
        // probably be pre-emptively hedged.
        //
        // The Hedge goes outside the Retry, because the Retry layer
        // abstracts away spurious failures from individual peers
        // making a less-fallible network service, and the Hedge layer
        // tries to reduce latency of that less-fallible service.
        //
        // XXX add ServiceBuilder::hedge() so this becomes
        // ServiceBuilder::new().hedge(...).retry(...)...
        let block_network = Hedge::new(
            ServiceBuilder::new()
                .concurrency_limit(config.sync.max_concurrent_block_requests)
                .retry(zn::RetryLimit::new(BLOCK_DOWNLOAD_RETRY_LIMIT))
                .timeout(BLOCK_DOWNLOAD_TIMEOUT)
                .service(peers),
            AlwaysHedge,
            20,
            0.95,
            2 * SYNC_RESTART_DELAY,
        );
        // We apply a timeout to the verifier to avoid hangs due to missing earlier blocks.
        let verifier = Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT);
        assert!(
            config.sync.lookahead_limit >= MIN_LOOKAHEAD_LIMIT,
            "configured lookahead limit {} too low, must be at least {}",
            config.sync.lookahead_limit,
            MIN_LOOKAHEAD_LIMIT
        );
        let (sync_status, recent_syncs) = SyncStatus::new();
        let new_syncer = Self {
            genesis_hash: genesis_hash(config.network.network),
            lookahead_limit: config.sync.lookahead_limit,
            tip_network,
            downloads: Box::pin(Downloads::new(
                block_network,
                verifier,
                latest_chain_tip,
                config.sync.lookahead_limit,
            )),
            state,
            prospective_tips: HashSet::new(),
            recent_syncs,
        };
        (new_syncer, sync_status)
    }
pub fn new ( config : & ZebradConfig , peers : ZN , verifier : ZV , state : ZS , latest_chain_tip : LatestChainTip , ) -> ( Self , SyncStatus ) { let tip_network = Timeout :: new ( peers . clone ( ) , TIPS_RESPONSE_TIMEOUT ) ; // The Hedge middleware is the outermost layer, hedging requests // between two retry-wrapped networks.  The innermost timeout // layer is relatively unimportant, because slow requests will // probably be pre-emptively hedged. // // The Hedge goes outside the Retry, because the Retry layer // abstracts away spurious failures from individual peers // making a less-fallible network service, and the Hedge layer // tries to reduce latency of that less-fallible service. // // XXX add ServiceBuilder::hedge() so this becomes // ServiceBuilder::new().hedge(...).retry(...)... let block_network = Hedge :: new ( ServiceBuilder :: new ( ) . concurrency_limit ( config . sync . max_concurrent_block_requests ) . retry ( zn :: RetryLimit :: new ( BLOCK_DOWNLOAD_RETRY_LIMIT ) ) . timeout ( BLOCK_DOWNLOAD_TIMEOUT ) . service ( peers ) , AlwaysHedge , 20 , 0.95 , 2 * SYNC_RESTART_DELAY , ) ; // We apply a timeout to the verifier to avoid hangs due to missing earlier blocks. let verifier = Timeout :: new ( verifier , BLOCK_VERIFY_TIMEOUT ) ; assert ! ( config sync lookahead_limit MIN_LOOKAHEAD_LIMIT " " config sync lookahead_limit MIN_LOOKAHEAD_LIMIT ) ; let ( sync_status , recent_syncs ) = SyncStatus :: new ( ) ; let new_syncer = Self { genesis_hash : genesis_hash ( config . network . network ) , lookahead_limit : config . sync . lookahead_limit , tip_network , downloads : Box :: pin ( Downloads :: new ( block_network , verifier , latest_chain_tip , config . sync . lookahead_limit , ) ) , state , prospective_tips : HashSet :: new ( ) , recent_syncs , } ; ( new_syncer , sync_status ) }
Returns a new syncer instance, using:
 chain: the zebra-chain `Network` to download (Mainnet or Testnet)
 peers: the zebra-network peers to contact for downloads
 verifier: the zebra-consensus verifier that checks the chain
 state: the zebra-state that stores the chain
 latest_chain_tip: the latest chain tip from `state`
Returns a new syncer instance using : chain : the zebra - chain ` Network ` to download ( Mainnet or Testnet ) peers : the zebra - network peers to contact for downloads verifier : the zebra - consensus verifier that checks the chain state : the zebra - state that stores the chain latest_chain_tip : the latest chain tip from ` state `
config
&ZebradConfig
peers
ZN
verifier
ZV
state
ZS
latest_chain_tip
LatestChainTip