diff --git a/account-decoder/src/parse_nonce.rs b/account-decoder/src/parse_nonce.rs index 4726e2b16bc886..15942f41db50b8 100644 --- a/account-decoder/src/parse_nonce.rs +++ b/account-decoder/src/parse_nonce.rs @@ -5,13 +5,13 @@ use solana_sdk::{ nonce::{state::Versions, State}, }; -pub fn parse_nonce(data: &[u8]) -> Result { +pub fn parse_nonce(data: &[u8]) -> Result { let nonce_state: Versions = bincode::deserialize(data) .map_err(|_| ParseAccountError::from(InstructionError::InvalidAccountData))?; let nonce_state = nonce_state.convert_to_current(); match nonce_state { - State::Uninitialized => Ok(RpcNonceState::Uninitialized), - State::Initialized(data) => Ok(RpcNonceState::Initialized(RpcNonceData { + State::Uninitialized => Ok(DisplayNonceState::Uninitialized), + State::Initialized(data) => Ok(DisplayNonceState::Initialized(DisplayNonceData { authority: data.authority.to_string(), blockhash: data.blockhash.to_string(), fee_calculator: data.fee_calculator, @@ -21,14 +21,14 @@ pub fn parse_nonce(data: &[u8]) -> Result { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub enum RpcNonceState { +pub enum DisplayNonceState { Uninitialized, - Initialized(RpcNonceData), + Initialized(DisplayNonceData), } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct RpcNonceData { +pub struct DisplayNonceData { pub authority: String, pub blockhash: String, pub fee_calculator: FeeCalculator, diff --git a/account-decoder/src/parse_vote.rs b/account-decoder/src/parse_vote.rs index fd91c3a5922eb8..135cc321f8da27 100644 --- a/account-decoder/src/parse_vote.rs +++ b/account-decoder/src/parse_vote.rs @@ -5,12 +5,12 @@ use solana_sdk::{ }; use solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState}; -pub fn parse_vote(data: &[u8]) -> Result { +pub fn parse_vote(data: &[u8]) -> Result { let mut vote_state = VoteState::deserialize(data).map_err(ParseAccountError::from)?; let epoch_credits = vote_state .epoch_credits() .iter() - .map(|(epoch, credits, previous_credits)| RpcEpochCredits { + .map(|(epoch, credits, previous_credits)| DisplayEpochCredits { epoch: *epoch, credits: *credits, previous_credits: *previous_credits, @@ -19,7 +19,7 @@ pub fn parse_vote(data: &[u8]) -> Result { let votes = vote_state .votes .iter() - .map(|lockout| RpcLockout { + .map(|lockout| DisplayLockout { slot: lockout.slot, confirmation_count: lockout.confirmation_count, }) @@ -27,7 +27,7 @@ pub fn parse_vote(data: &[u8]) -> Result { let authorized_voters = vote_state .authorized_voters() .iter() - .map(|(epoch, authorized_voter)| RpcAuthorizedVoters { + .map(|(epoch, authorized_voter)| DisplayAuthorizedVoters { epoch: *epoch, authorized_voter: authorized_voter.to_string(), }) @@ -38,14 +38,16 @@ pub fn parse_vote(data: &[u8]) -> Result { .iter() .filter(|(pubkey, _, _)| pubkey != &Pubkey::default()) .map( - |(authorized_pubkey, epoch_of_last_authorized_switch, target_epoch)| RpcPriorVoters { - authorized_pubkey: authorized_pubkey.to_string(), - epoch_of_last_authorized_switch: *epoch_of_last_authorized_switch, - target_epoch: *target_epoch, + |(authorized_pubkey, epoch_of_last_authorized_switch, target_epoch)| { + DisplayPriorVoters { + authorized_pubkey: authorized_pubkey.to_string(), + epoch_of_last_authorized_switch: *epoch_of_last_authorized_switch, + target_epoch: *target_epoch, + } }, ) .collect(); - Ok(RpcVoteState { + Ok(DisplayVoteState { node_pubkey: vote_state.node_pubkey.to_string(), authorized_withdrawer: vote_state.authorized_withdrawer.to_string(), commission: vote_state.commission, @@ -61,26 +63,26 @@ pub fn parse_vote(data: &[u8]) -> Result { /// A duplicate representation of VoteState for pretty JSON serialization #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct RpcVoteState { +pub struct DisplayVoteState { node_pubkey: String, authorized_withdrawer: String, commission: u8, - votes: Vec, + votes: Vec, root_slot: Option, - authorized_voters: Vec, - prior_voters: Vec, - epoch_credits: Vec, + authorized_voters: Vec, + prior_voters: Vec, + epoch_credits: Vec, last_timestamp: BlockTimestamp, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -struct RpcLockout { +struct DisplayLockout { slot: Slot, confirmation_count: u32, } -impl From<&Lockout> for RpcLockout { +impl From<&Lockout> for DisplayLockout { fn from(lockout: &Lockout) -> Self { Self { slot: lockout.slot, @@ -91,14 +93,14 @@ impl From<&Lockout> for RpcLockout { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -struct RpcAuthorizedVoters { +struct DisplayAuthorizedVoters { epoch: Epoch, authorized_voter: String, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -struct RpcPriorVoters { +struct DisplayPriorVoters { authorized_pubkey: String, epoch_of_last_authorized_switch: Epoch, target_epoch: Epoch, @@ -106,7 +108,7 @@ struct RpcPriorVoters { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -struct RpcEpochCredits { +struct DisplayEpochCredits { epoch: Epoch, credits: u64, previous_credits: u64,