parent
97be2ca295
commit
d7b9d0dd9f
@ -519,10 +519,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
let mut out_list = enr.multiaddr();
|
let mut out_list = enr.multiaddr();
|
||||||
out_list.retain(|addr| {
|
out_list.retain(|addr| {
|
||||||
addr.iter()
|
addr.iter()
|
||||||
.find(|v| match v {
|
.find(|v| matches!(v, MProtocol::Udp(_)))
|
||||||
MProtocol::Udp(_) => true,
|
|
||||||
_ => false,
|
|
||||||
})
|
|
||||||
.is_none()
|
.is_none()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -228,18 +228,12 @@ impl Default for PeerConnectionStatus {
|
|||||||
impl PeerConnectionStatus {
|
impl PeerConnectionStatus {
|
||||||
/// Checks if the status is connected.
|
/// Checks if the status is connected.
|
||||||
pub fn is_connected(&self) -> bool {
|
pub fn is_connected(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerConnectionStatus::Connected { .. })
|
||||||
PeerConnectionStatus::Connected { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the status is connected.
|
/// Checks if the status is connected.
|
||||||
pub fn is_dialing(&self) -> bool {
|
pub fn is_dialing(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerConnectionStatus::Dialing { .. })
|
||||||
PeerConnectionStatus::Dialing { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The peer is either connected or in the process of being dialed.
|
/// The peer is either connected or in the process of being dialed.
|
||||||
@ -249,18 +243,12 @@ impl PeerConnectionStatus {
|
|||||||
|
|
||||||
/// Checks if the status is banned.
|
/// Checks if the status is banned.
|
||||||
pub fn is_banned(&self) -> bool {
|
pub fn is_banned(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerConnectionStatus::Banned { .. })
|
||||||
PeerConnectionStatus::Banned { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the status is disconnected.
|
/// Checks if the status is disconnected.
|
||||||
pub fn is_disconnected(&self) -> bool {
|
pub fn is_disconnected(&self) -> bool {
|
||||||
match self {
|
matches!(self, Disconnected { .. })
|
||||||
Disconnected { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies the status to Connected and increases the number of ingoing
|
/// Modifies the status to Connected and increases the number of ingoing
|
||||||
|
@ -29,26 +29,17 @@ pub struct SyncInfo {
|
|||||||
impl PeerSyncStatus {
|
impl PeerSyncStatus {
|
||||||
/// Returns true if the peer has advanced knowledge of the chain.
|
/// Returns true if the peer has advanced knowledge of the chain.
|
||||||
pub fn is_advanced(&self) -> bool {
|
pub fn is_advanced(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerSyncStatus::Advanced { .. })
|
||||||
PeerSyncStatus::Advanced { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the peer is up to date with the current chain.
|
/// Returns true if the peer is up to date with the current chain.
|
||||||
pub fn is_synced(&self) -> bool {
|
pub fn is_synced(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerSyncStatus::Synced { .. })
|
||||||
PeerSyncStatus::Synced { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the peer is behind the current chain.
|
/// Returns true if the peer is behind the current chain.
|
||||||
pub fn is_behind(&self) -> bool {
|
pub fn is_behind(&self) -> bool {
|
||||||
match self {
|
matches!(self, PeerSyncStatus::Behind { .. })
|
||||||
PeerSyncStatus::Behind { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the sync state given a fully synced peer.
|
/// Updates the sync state given a fully synced peer.
|
||||||
|
@ -136,20 +136,16 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
|||||||
|
|
||||||
/// Returns if the peer is already connected.
|
/// Returns if the peer is already connected.
|
||||||
pub fn is_connected(&self, peer_id: &PeerId) -> bool {
|
pub fn is_connected(&self, peer_id: &PeerId) -> bool {
|
||||||
if let Some(PeerConnectionStatus::Connected { .. }) = self.connection_status(peer_id) {
|
matches!(
|
||||||
true
|
self.connection_status(peer_id),
|
||||||
} else {
|
Some(PeerConnectionStatus::Connected { .. })
|
||||||
false
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If we are connected or currently dialing the peer returns true.
|
/// If we are connected or currently dialing the peer returns true.
|
||||||
pub fn is_connected_or_dialing(&self, peer_id: &PeerId) -> bool {
|
pub fn is_connected_or_dialing(&self, peer_id: &PeerId) -> bool {
|
||||||
match self.connection_status(peer_id) {
|
matches!(self.connection_status(peer_id), Some(PeerConnectionStatus::Connected { .. })
|
||||||
Some(PeerConnectionStatus::Connected { .. })
|
| Some(PeerConnectionStatus::Dialing { .. }))
|
||||||
| Some(PeerConnectionStatus::Dialing { .. }) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// Returns true if the peer is synced at least to our current head.
|
/// Returns true if the peer is synced at least to our current head.
|
||||||
pub fn is_synced(&self, peer_id: &PeerId) -> bool {
|
pub fn is_synced(&self, peer_id: &PeerId) -> bool {
|
||||||
|
@ -277,10 +277,7 @@ impl<T: EthSpec> RPCCodedResponse<T> {
|
|||||||
|
|
||||||
/// Tells the codec whether to decode as an RPCResponse or an error.
|
/// Tells the codec whether to decode as an RPCResponse or an error.
|
||||||
pub fn is_response(response_code: u8) -> bool {
|
pub fn is_response(response_code: u8) -> bool {
|
||||||
match response_code {
|
matches!(response_code, 0)
|
||||||
0 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds an RPCCodedResponse from a response code and an ErrorMessage
|
/// Builds an RPCCodedResponse from a response code and an ErrorMessage
|
||||||
@ -311,10 +308,7 @@ impl<T: EthSpec> RPCCodedResponse<T> {
|
|||||||
|
|
||||||
/// Returns true if this response always terminates the stream.
|
/// Returns true if this response always terminates the stream.
|
||||||
pub fn close_after(&self) -> bool {
|
pub fn close_after(&self) -> bool {
|
||||||
match self {
|
!matches!(self, RPCCodedResponse::Success(_))
|
||||||
RPCCodedResponse::Success(_) => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,7 @@ impl SyncState {
|
|||||||
|
|
||||||
/// Returns true if the node is synced.
|
/// Returns true if the node is synced.
|
||||||
pub fn is_synced(&self) -> bool {
|
pub fn is_synced(&self) -> bool {
|
||||||
match self {
|
matches!(self, SyncState::Synced)
|
||||||
SyncState::Synced => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,10 +156,7 @@ impl MerkleTree {
|
|||||||
|
|
||||||
/// Is this Merkle tree a leaf?
|
/// Is this Merkle tree a leaf?
|
||||||
pub fn is_leaf(&self) -> bool {
|
pub fn is_leaf(&self) -> bool {
|
||||||
match self {
|
matches!(self, MerkleTree::Leaf(_))
|
||||||
MerkleTree::Leaf(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the leaf at `index` and a Merkle proof of its inclusion.
|
/// Return the leaf at `index` and a Merkle proof of its inclusion.
|
||||||
|
@ -37,9 +37,6 @@ impl Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_skipped(&self) -> bool {
|
pub fn is_skipped(&self) -> bool {
|
||||||
match self {
|
matches!(self, Error::SkippedBls | Error::SkippedKnownFailure)
|
||||||
Error::SkippedBls | Error::SkippedKnownFailure => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user