Send votes from banking stage to vote listener (#11434)
* Send votes from banking stage to vote listener Co-authored-by: Carl <carl@solana.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
use crate::{
|
||||
bank::Bank,
|
||||
bank::{Bank, TransactionResults},
|
||||
genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
|
||||
vote_sender_types::ReplayVoteSender,
|
||||
};
|
||||
use solana_sdk::{pubkey::Pubkey, signature::Signer};
|
||||
use solana_sdk::{pubkey::Pubkey, signature::Signer, transaction::Transaction};
|
||||
use solana_vote_program::vote_transaction;
|
||||
|
||||
pub fn setup_bank_and_vote_pubkeys(num_vote_accounts: usize, stake: u64) -> (Bank, Vec<Pubkey>) {
|
||||
// Create some voters at genesis
|
||||
@@ -23,3 +25,28 @@ pub fn setup_bank_and_vote_pubkeys(num_vote_accounts: usize, stake: u64) -> (Ban
|
||||
let bank = Bank::new(&genesis_config);
|
||||
(bank, vote_pubkeys)
|
||||
}
|
||||
|
||||
pub fn find_and_send_votes(
|
||||
txs: &[Transaction],
|
||||
tx_results: &TransactionResults,
|
||||
vote_sender: Option<&ReplayVoteSender>,
|
||||
) {
|
||||
let TransactionResults {
|
||||
processing_results,
|
||||
overwritten_vote_accounts,
|
||||
..
|
||||
} = tx_results;
|
||||
if let Some(vote_sender) = vote_sender {
|
||||
for old_account in overwritten_vote_accounts {
|
||||
assert!(processing_results[old_account.transaction_result_index]
|
||||
.0
|
||||
.is_ok());
|
||||
let transaction = &txs[old_account.transaction_index];
|
||||
if let Some(parsed_vote) = vote_transaction::parse_vote_transaction(transaction) {
|
||||
if parsed_vote.1.slots.last().is_some() {
|
||||
let _ = vote_sender.send(parsed_vote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user