Admin add/remove peer (#7198)

N/A


  Adds endpoints to add and remove trusted peers from the http api. The added peers are trusted peers so they won't be disconnected for bad scores. We try to maintain a connection to the peer in case they disconnect from us by trying to dial it every heartbeat.
This commit is contained in:
Pawan Dhananjay
2025-03-28 05:59:09 -07:00
committed by GitHub
parent a5ea05ce2a
commit 54aef2d043
10 changed files with 217 additions and 7 deletions

View File

@@ -1236,6 +1236,21 @@ impl<E: EthSpec> Network<E> {
}
}
/// Adds the given `enr` to the trusted peers mapping and tries to dial it
/// every heartbeat to maintain the connection.
pub fn dial_trusted_peer(&mut self, enr: Enr) {
self.peer_manager_mut().add_trusted_peer(enr.clone());
self.peer_manager_mut().dial_peer(enr);
}
/// Remove the given peer from the trusted peers mapping if it exists and disconnect
/// from it.
pub fn remove_trusted_peer(&mut self, enr: Enr) {
self.peer_manager_mut().remove_trusted_peer(enr.clone());
self.peer_manager_mut()
.disconnect_peer(enr.peer_id(), GoodbyeReason::TooManyPeers);
}
/* Sub-behaviour event handling functions */
/// Handle a gossipsub event.