mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 11:52:42 +00:00
Use existing peer count metrics loop to check for open_nat toggle (#6800)
* implement update_nat_open function in network_behaviour for tracking incoming peers below a given threshold count * implement update_nat_open function in network_behaviour for tracking incoming peers below a given threshold count * tidy logic and comments * move logic to existing metrics loop * revert change to network_behaviour protocol check * clippy * clippy matches! macro * pull nat_open check outside of peercounting loop * missing close bracket * make threshold const
This commit is contained in:
@@ -122,6 +122,24 @@ impl<E: EthSpec> PeerInfo<E> {
|
||||
self.connection_direction.as_ref()
|
||||
}
|
||||
|
||||
/// Returns true if this is an incoming ipv4 connection.
|
||||
pub fn is_incoming_ipv4_connection(&self) -> bool {
|
||||
self.seen_multiaddrs.iter().any(|multiaddr| {
|
||||
multiaddr
|
||||
.iter()
|
||||
.any(|protocol| matches!(protocol, libp2p::core::multiaddr::Protocol::Ip4(_)))
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns true if this is an incoming ipv6 connection.
|
||||
pub fn is_incoming_ipv6_connection(&self) -> bool {
|
||||
self.seen_multiaddrs.iter().any(|multiaddr| {
|
||||
multiaddr
|
||||
.iter()
|
||||
.any(|protocol| matches!(protocol, libp2p::core::multiaddr::Protocol::Ip6(_)))
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the sync status of the peer.
|
||||
pub fn sync_status(&self) -> &SyncStatus {
|
||||
&self.sync_status
|
||||
|
||||
Reference in New Issue
Block a user