Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions beacon_node/network/src/sync/range_sync/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const BATCH_BUFFER_SIZE: u8 = 5;
pub type ProcessingResult = Result<KeepChain, RemoveChain>;

/// Reasons for removing a chain
#[derive(Debug)]
pub enum RemoveChain {
EmptyPeerPool,
ChainCompleted,
Expand Down Expand Up @@ -101,7 +102,7 @@ pub struct SyncingChain<T: BeaconChainTypes> {
log: slog::Logger,
}

#[derive(PartialEq)]
#[derive(PartialEq, Debug)]
pub enum ChainSyncingState {
/// The chain is not being synced.
Stopped,
Expand Down Expand Up @@ -764,9 +765,6 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
network: &mut SyncNetworkContext<T::EthSpec>,
peer_id: PeerId,
) -> ProcessingResult {
if let ChainSyncingState::Stopped = self.state {
debug!(self.log, "Peer added to non-syncing chain"; "peer" => %peer_id)
}
// add the peer without overwriting its active requests
if self.peers.entry(peer_id).or_default().is_empty() {
// Either new or not, this peer is idle, try to request more batches
Expand Down Expand Up @@ -1041,6 +1039,7 @@ impl<T: BeaconChainTypes> slog::KV for SyncingChain<T> {
serializer.emit_usize("batches", self.batches.len())?;
serializer.emit_usize("peers", self.peers.len())?;
serializer.emit_u8("validated_batches", self.validated_batches)?;
serializer.emit_arguments("state", &format_args!("{:?}", self.state))?;
slog::Result::Ok(())
}
}
Expand All @@ -1052,19 +1051,6 @@ impl From<WrongBatchState> for RemoveChain {
}
}

impl std::fmt::Debug for RemoveChain {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// needed to avoid Debugging Strings
match self {
RemoveChain::ChainCompleted => f.write_str("ChainCompleted"),
RemoveChain::EmptyPeerPool => f.write_str("EmptyPeerPool"),
RemoveChain::ChainFailed(batch) => write!(f, "ChainFailed(batch: {} )", batch),
RemoveChain::WrongBatchState(reason) => write!(f, "WrongBatchState: {}", reason),
RemoveChain::WrongChainState(reason) => write!(f, "WrongChainState: {}", reason),
}
}
}

impl RemoveChain {
pub fn is_critical(&self) -> bool {
matches!(
Expand Down