refactor to remove additional is_simple_vote check (#30521)
This commit is contained in:
parent
ee81679804
commit
9ec5e9b866
|
@ -77,7 +77,6 @@ use {
|
|||
transaction_batch::TransactionBatch,
|
||||
transaction_error_metrics::TransactionErrorMetrics,
|
||||
vote_account::{VoteAccount, VoteAccountsHashMap},
|
||||
vote_parser,
|
||||
},
|
||||
byteorder::{ByteOrder, LittleEndian},
|
||||
dashmap::{DashMap, DashSet},
|
||||
|
@ -4672,7 +4671,7 @@ impl Bank {
|
|||
}
|
||||
}
|
||||
|
||||
let is_vote = vote_parser::is_simple_vote_transaction(tx);
|
||||
let is_vote = tx.is_simple_vote_transaction();
|
||||
|
||||
if execution_result.was_executed() // Skip log collection for unprocessed transactions
|
||||
&& transaction_log_collector_config.filter != TransactionLogCollectorFilter::None
|
||||
|
|
|
@ -12,24 +12,6 @@ use {
|
|||
|
||||
pub type ParsedVote = (Pubkey, VoteTransaction, Option<Hash>, Signature);
|
||||
|
||||
// Used for filtering out votes from the transaction log collector
|
||||
pub(crate) fn is_simple_vote_transaction(transaction: &SanitizedTransaction) -> bool {
|
||||
if transaction.message().instructions().len() == 1 {
|
||||
let (program_pubkey, instruction) = transaction
|
||||
.message()
|
||||
.program_instructions_iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
if program_pubkey == &solana_vote_program::id() {
|
||||
if let Ok(vote_instruction) = limited_deserialize::<VoteInstruction>(&instruction.data)
|
||||
{
|
||||
return vote_instruction.is_simple_vote();
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
// Used for locally forwarding processed vote transactions to consensus
|
||||
pub fn parse_sanitized_vote_transaction(tx: &SanitizedTransaction) -> Option<ParsedVote> {
|
||||
// Check first instruction for a vote
|
||||
|
|
|
@ -117,9 +117,13 @@ impl SanitizedTransaction {
|
|||
};
|
||||
|
||||
let is_simple_vote_tx = is_simple_vote_tx.unwrap_or_else(|| {
|
||||
// TODO: Move to `vote_parser` runtime module
|
||||
let mut ix_iter = message.program_instructions_iter();
|
||||
ix_iter.next().map(|(program_id, _ix)| program_id) == Some(&crate::vote::program::id())
|
||||
if message.instructions().len() == 1 && matches!(message, SanitizedMessage::Legacy(_)) {
|
||||
let mut ix_iter = message.program_instructions_iter();
|
||||
ix_iter.next().map(|(program_id, _ix)| program_id)
|
||||
== Some(&crate::vote::program::id())
|
||||
} else {
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
|
|
Loading…
Reference in New Issue