solana catchup
now detects when you try to catchup to yourself (#8635)
automerge
This commit is contained in:
@ -6,8 +6,8 @@ use crate::{
|
||||
rpc_request::RpcRequest,
|
||||
rpc_response::{
|
||||
Response, RpcAccount, RpcBlockhashFeeCalculator, RpcConfirmedBlock, RpcContactInfo,
|
||||
RpcEpochInfo, RpcFeeRateGovernor, RpcKeyedAccount, RpcLeaderSchedule, RpcResponse,
|
||||
RpcVersionInfo, RpcVoteAccountStatus,
|
||||
RpcEpochInfo, RpcFeeRateGovernor, RpcIdentity, RpcKeyedAccount, RpcLeaderSchedule,
|
||||
RpcResponse, RpcVersionInfo, RpcVoteAccountStatus,
|
||||
},
|
||||
};
|
||||
use bincode::serialize;
|
||||
@ -356,6 +356,34 @@ impl RpcClient {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_identity(&self) -> io::Result<Pubkey> {
|
||||
let response = self
|
||||
.client
|
||||
.send(&RpcRequest::GetIdentity, Value::Null, 0)
|
||||
.map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetIdentity request failure: {:?}", err),
|
||||
)
|
||||
})?;
|
||||
|
||||
serde_json::from_value(response)
|
||||
.map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetIdentity failure: {:?}", err),
|
||||
)
|
||||
})
|
||||
.and_then(|rpc_identity: RpcIdentity| {
|
||||
rpc_identity.identity.parse::<Pubkey>().map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetIdentity invalid pubkey failure: {:?}", err),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_inflation(&self) -> io::Result<Inflation> {
|
||||
let response = self
|
||||
.client
|
||||
|
@ -15,6 +15,7 @@ pub enum RpcRequest {
|
||||
GetEpochInfo,
|
||||
GetEpochSchedule,
|
||||
GetGenesisHash,
|
||||
GetIdentity,
|
||||
GetInflation,
|
||||
GetLeaderSchedule,
|
||||
GetNumBlocksSinceSignatureConfirmation,
|
||||
@ -55,6 +56,7 @@ impl RpcRequest {
|
||||
RpcRequest::GetEpochInfo => "getEpochInfo",
|
||||
RpcRequest::GetEpochSchedule => "getEpochSchedule",
|
||||
RpcRequest::GetGenesisHash => "getGenesisHash",
|
||||
RpcRequest::GetIdentity => "getIdentity",
|
||||
RpcRequest::GetInflation => "getInflation",
|
||||
RpcRequest::GetLeaderSchedule => "getLeaderSchedule",
|
||||
RpcRequest::GetNumBlocksSinceSignatureConfirmation => {
|
||||
|
@ -241,6 +241,13 @@ pub struct RpcVersionInfo {
|
||||
pub solana_core: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct RpcIdentity {
|
||||
/// The current node identity pubkey
|
||||
pub identity: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcVoteAccountStatus {
|
||||
|
Reference in New Issue
Block a user