mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 19:32:55 +00:00
## Proposed Changes
This reverts commit 53562010ec from PR #2724
Hopefully this will restore the reliability of the sync simulator.
This commit is contained in:
@@ -236,6 +236,7 @@ impl<T: EthSpec> PeerInfo<T> {
|
||||
/* Mutable Functions */
|
||||
|
||||
/// Updates the sync status. Returns true if the status was changed.
|
||||
// VISIBILITY: Both the peer manager the network sync is able to update the sync state of a peer
|
||||
pub fn update_sync_status(&mut self, sync_status: SyncStatus) -> bool {
|
||||
self.sync_status.update(sync_status)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,19 @@ pub struct SyncInfo {
|
||||
pub finalized_root: Hash256,
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq for SyncStatus {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
matches!(
|
||||
(self, other),
|
||||
(SyncStatus::Synced { .. }, SyncStatus::Synced { .. })
|
||||
| (SyncStatus::Advanced { .. }, SyncStatus::Advanced { .. })
|
||||
| (SyncStatus::Behind { .. }, SyncStatus::Behind { .. })
|
||||
| (SyncStatus::IrrelevantPeer, SyncStatus::IrrelevantPeer)
|
||||
| (SyncStatus::Unknown, SyncStatus::Unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl SyncStatus {
|
||||
/// Returns true if the peer has advanced knowledge of the chain.
|
||||
pub fn is_advanced(&self) -> bool {
|
||||
@@ -48,7 +61,7 @@ impl SyncStatus {
|
||||
/// E.g. returns `true` if the state changed from `Synced` to `Advanced`, but not if
|
||||
/// the status remained `Synced` with different `SyncInfo` within.
|
||||
pub fn update(&mut self, new_state: SyncStatus) -> bool {
|
||||
let changed_status = !(self.is_same_kind(&new_state));
|
||||
let changed_status = *self != new_state;
|
||||
*self = new_state;
|
||||
changed_status
|
||||
}
|
||||
@@ -62,17 +75,6 @@ impl SyncStatus {
|
||||
SyncStatus::IrrelevantPeer => "Irrelevant",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_same_kind(&self, other: &Self) -> bool {
|
||||
matches!(
|
||||
(self, other),
|
||||
(SyncStatus::Synced { .. }, SyncStatus::Synced { .. })
|
||||
| (SyncStatus::Advanced { .. }, SyncStatus::Advanced { .. })
|
||||
| (SyncStatus::Behind { .. }, SyncStatus::Behind { .. })
|
||||
| (SyncStatus::IrrelevantPeer, SyncStatus::IrrelevantPeer)
|
||||
| (SyncStatus::Unknown, SyncStatus::Unknown)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SyncStatus {
|
||||
|
||||
Reference in New Issue
Block a user