Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions vote-interface/src/state/vote_state_v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use solana_frozen_abi_macro::{frozen_abi, AbiExample};
#[cfg(any(target_os = "solana", feature = "bincode"))]
use solana_instruction::error::InstructionError;
use {
super::{BlockTimestamp, LandedVote, BLS_PUBLIC_KEY_COMPRESSED_SIZE},
super::{BlockTimestamp, LandedVote, VoteInit, BLS_PUBLIC_KEY_COMPRESSED_SIZE},
crate::authorized_voters::AuthorizedVoters,
solana_clock::{Epoch, Slot},
solana_clock::{Clock, Epoch, Slot},
solana_pubkey::Pubkey,
std::{collections::VecDeque, fmt::Debug},
};
Expand Down Expand Up @@ -77,6 +77,21 @@ impl VoteStateV4 {
3762 // Same size as V3 to avoid account resizing
}

pub fn new(vote_pubkey: &Pubkey, vote_init: &VoteInit, clock: &Clock) -> Self {
Self {
node_pubkey: vote_init.node_pubkey,
authorized_voters: AuthorizedVoters::new(clock.epoch, vote_init.authorized_voter),
authorized_withdrawer: vote_init.authorized_withdrawer,
// SAFETY: u16::MAX > u8::MAX * 100
inflation_rewards_commission_bps: (vote_init.commission as u16).saturating_mul(100),
// Per SIMD-0185, set default collectors and commission.
inflation_rewards_collector: *vote_pubkey,
block_revenue_collector: vote_init.node_pubkey,
block_revenue_commission_bps: 10_000, // 100%
..Self::default()
}
}

#[cfg(any(target_os = "solana", feature = "bincode"))]
pub fn deserialize(input: &[u8], vote_pubkey: &Pubkey) -> Result<Self, InstructionError> {
let mut vote_state = Self::default();
Expand Down