compute_bank_stats needs to return newly computed ForkStats (#8608) (#8634)

* Fix broken confirmation, add test

(cherry picked from commit f23dc11a86)

Co-authored-by: carllin <wumu727@gmail.com>
This commit is contained in:
carllin
2020-03-04 14:28:17 -08:00
committed by GitHub
parent 298b7de2e2
commit dd06001ed8
3 changed files with 150 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
pub mod authorized_voters;
pub mod vote_instruction;
pub mod vote_state;
pub mod vote_transaction;
#[macro_use]
extern crate solana_metrics;

View File

@@ -0,0 +1,30 @@
use solana_sdk::{
clock::Slot,
hash::Hash,
signature::{Keypair, Signer},
transaction::Transaction,
};
use crate::{vote_instruction, vote_state::Vote};
pub fn new_vote_transaction(
slots: Vec<Slot>,
bank_hash: Hash,
blockhash: Hash,
node_keypair: &Keypair,
vote_keypair: &Keypair,
authorized_voter_keypair: &Keypair,
) -> Transaction {
let votes = Vote::new(slots, bank_hash);
let vote_ix = vote_instruction::vote(
&vote_keypair.pubkey(),
&authorized_voter_keypair.pubkey(),
votes,
);
let mut vote_tx = Transaction::new_with_payer(vec![vote_ix], Some(&node_keypair.pubkey()));
vote_tx.partial_sign(&[node_keypair], blockhash);
vote_tx.partial_sign(&[authorized_voter_keypair], blockhash);
vote_tx
}