Refactor: move simple vote parsing to runtime (#22537)

This commit is contained in:
Justin Starry
2022-01-20 10:39:21 +08:00
committed by GitHub
parent d343713f61
commit 7f20c6149e
16 changed files with 239 additions and 220 deletions

View File

@ -53,7 +53,7 @@ use {
},
},
solana_rayon_threadlimit::get_thread_count,
solana_runtime::bank_forks::BankForks,
solana_runtime::{bank_forks::BankForks, vote_parser},
solana_sdk::{
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
feature_set::FeatureSet,
@ -70,9 +70,7 @@ use {
socket::SocketAddrSpace,
streamer::{PacketBatchReceiver, PacketBatchSender},
},
solana_vote_program::{
vote_state::MAX_LOCKOUT_HISTORY, vote_transaction::parse_vote_transaction,
},
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
std::{
borrow::Cow,
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
@ -1037,7 +1035,7 @@ impl ClusterInfo {
};
let vote_index = vote_index.unwrap_or(num_crds_votes);
if (vote_index as usize) >= MAX_LOCKOUT_HISTORY {
let (_, vote, hash) = parse_vote_transaction(&vote).unwrap();
let (_, vote, hash) = vote_parser::parse_vote_transaction(&vote).unwrap();
panic!(
"invalid vote index: {}, switch: {}, vote slots: {:?}, tower: {:?}",
vote_index,

View File

@ -9,6 +9,7 @@ use {
bincode::{serialize, serialized_size},
rand::{CryptoRng, Rng},
serde::de::{Deserialize, Deserializer},
solana_runtime::vote_parser,
solana_sdk::{
clock::Slot,
hash::Hash,
@ -18,7 +19,6 @@ use {
timing::timestamp,
transaction::Transaction,
},
solana_vote_program::vote_transaction::parse_vote_transaction,
std::{
borrow::{Borrow, Cow},
cmp::Ordering,
@ -307,7 +307,7 @@ impl Sanitize for Vote {
impl Vote {
// Returns None if cannot parse transaction into a vote.
pub fn new(from: Pubkey, transaction: Transaction, wallclock: u64) -> Option<Self> {
parse_vote_transaction(&transaction).map(|(_, vote, _)| Self {
vote_parser::parse_vote_transaction(&transaction).map(|(_, vote, _)| Self {
from,
transaction,
wallclock,