fn determine_sync_mode(local: &ChainMetadata, network: ChainMetadata, sync_peers: SyncPeers) -> SyncStatus {
    use SyncStatus::*;
    match network.accumulated_difficulty {
        None => {
            info!(
                target: LOG_TARGET,
                "The rest of the network doesn't appear to have any up-to-date chain data, so we're going to assume \
                 we're at the tip"
            );
            UpToDate
        },
        Some(network_tip_accum_difficulty) => {
            let local_tip_accum_difficulty = local.accumulated_difficulty.unwrap_or_else(|| 0);
            if local_tip_accum_difficulty < network_tip_accum_difficulty {
                let local_tip_height = local.height_of_longest_chain();
                let network_tip_height = network.height_of_longest_chain();
                info!(
                    target: LOG_TARGET,
                    "Our local blockchain accumulated difficulty is a little behind that of the network. We're at \
                     block #{} with an accumulated difficulty of {}, and the network chain tip is at #{} with an \
                     accumulated difficulty of {}",
                    local_tip_height,
                    local_tip_accum_difficulty,
                    network_tip_height,
                    network_tip_accum_difficulty,
                );

                let network_horizon_block = local.horizon_block(network_tip_height);
                if local_tip_height < network_horizon_block {
                    LaggingBehindHorizon(network, sync_peers)
                } else {
                    Lagging(network, sync_peers)
                }
            } else {
                info!(
                    target: LOG_TARGET,
                    "Our blockchain is up-to-date. We're at block {} with an accumulated difficulty of {} and the \
                     network chain tip is at {} with an accumulated difficulty of {}",
                    local.height_of_longest_chain(),
                    local_tip_accum_difficulty,
                    network.height_of_longest_chain(),
                    network_tip_accum_difficulty,
                );
                UpToDate
            }
        },
    }
}
/// Given a local and the network chain state respectively, figure out what synchronisation state we should be in.
Given a local and the network chain state respectively, figure out what synchronisation state we should be in.
Given a local and the network chain state respectively figure out what synchronisation state we should be in .
fn determine_sync_mode(local: &ChainMetadata, network: ChainMetadata, sync_peers: SyncPeers) -> SyncStatus {
    use SyncStatus::*;
    match network.accumulated_difficulty {
        None => {
            info!(
                target: LOG_TARGET,
                "The rest of the network doesn't appear to have any up-to-date chain data, so we're going to assume \
                 we're at the tip"
            );
            UpToDate
        },
        Some(network_tip_accum_difficulty) => {
            let local_tip_accum_difficulty = local.accumulated_difficulty.unwrap_or_else(|| 0);
            if local_tip_accum_difficulty < network_tip_accum_difficulty {
                let local_tip_height = local.height_of_longest_chain();
                let network_tip_height = network.height_of_longest_chain();
                info!(
                    target: LOG_TARGET,
                    "Our local blockchain accumulated difficulty is a little behind that of the network. We're at \
                     block #{} with an accumulated difficulty of {}, and the network chain tip is at #{} with an \
                     accumulated difficulty of {}",
                    local_tip_height,
                    local_tip_accum_difficulty,
                    network_tip_height,
                    network_tip_accum_difficulty,
                );
                let network_horizon_block = local.horizon_block(network_tip_height);
                if local_tip_height < network_horizon_block {
                    LaggingBehindHorizon(network, sync_peers)
                } else {
                    Lagging(network, sync_peers)
                }
            } else {
                info!(
                    target: LOG_TARGET,
                    "Our blockchain is up-to-date. We're at block {} with an accumulated difficulty of {} and the \
                     network chain tip is at {} with an accumulated difficulty of {}",
                    local.height_of_longest_chain(),
                    local_tip_accum_difficulty,
                    network.height_of_longest_chain(),
                    network_tip_accum_difficulty,
                );
                UpToDate
            }
        },
    }
}
fn determine_sync_mode ( local : & ChainMetadata , network : ChainMetadata , sync_peers : SyncPeers ) -> SyncStatus { use SyncStatus :: * ; match network . accumulated_difficulty { None => { info ! ( target LOG_TARGET " \
 " ) ; UpToDate } , Some ( network_tip_accum_difficulty ) => { let local_tip_accum_difficulty = local . accumulated_difficulty . unwrap_or_else ( | | 0 ) ; if local_tip_accum_difficulty < network_tip_accum_difficulty { let local_tip_height = local . height_of_longest_chain ( ) ; let network_tip_height = network . height_of_longest_chain ( ) ; info ! ( target LOG_TARGET " \
 \
 " local_tip_height local_tip_accum_difficulty network_tip_height network_tip_accum_difficulty ) ; let network_horizon_block = local . horizon_block ( network_tip_height ) ; if local_tip_height < network_horizon_block { LaggingBehindHorizon ( network , sync_peers ) } else { Lagging ( network , sync_peers ) } } else { info ! ( target LOG_TARGET " \
 " local height_of_longest_chain ( ) local_tip_accum_difficulty network height_of_longest_chain ( ) network_tip_accum_difficulty ) ; UpToDate } } , } }
Given a local and the network chain state respectively, figure out what synchronisation state we should be in.
Given a local and the network chain state respectively figure out what synchronisation state we should be in .
local
&ChainMetadata
network
ChainMetadata
sync_peers
SyncPeers
local
&ChainMetadata
network
ChainMetadata
sync_peers
SyncPeers