mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
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:
@@ -9,7 +9,8 @@ mod sync_committee_rewards;
|
||||
|
||||
use crate::{
|
||||
types::{
|
||||
DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock, GenericResponse, ValidatorId,
|
||||
AdminPeer, DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock, GenericResponse,
|
||||
ValidatorId,
|
||||
},
|
||||
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, Slot,
|
||||
};
|
||||
@@ -406,6 +407,30 @@ impl BeaconNodeHttpClient {
|
||||
self.post_with_response(path, &()).await
|
||||
}
|
||||
|
||||
/// `POST lighthouse/add_peer`
|
||||
pub async fn post_lighthouse_add_peer(&self, req: AdminPeer) -> Result<(), Error> {
|
||||
let mut path = self.server.full.clone();
|
||||
|
||||
path.path_segments_mut()
|
||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
||||
.push("lighthouse")
|
||||
.push("add_peer");
|
||||
|
||||
self.post_with_response(path, &req).await
|
||||
}
|
||||
|
||||
/// `POST lighthouse/remove_peer`
|
||||
pub async fn post_lighthouse_remove_peer(&self, req: AdminPeer) -> Result<(), Error> {
|
||||
let mut path = self.server.full.clone();
|
||||
|
||||
path.path_segments_mut()
|
||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
||||
.push("lighthouse")
|
||||
.push("remove_peer");
|
||||
|
||||
self.post_with_response(path, &req).await
|
||||
}
|
||||
|
||||
/*
|
||||
Analysis endpoints.
|
||||
*/
|
||||
|
||||
@@ -1431,6 +1431,11 @@ pub struct ManualFinalizationRequestData {
|
||||
pub block_root: Hash256,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminPeer {
|
||||
pub enr: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct LivenessRequestData {
|
||||
pub epoch: Epoch,
|
||||
|
||||
Reference in New Issue
Block a user