Files
solana/src/voting.rs
Greg Fitzgerald ad331e6d56 Rename PublicKey type to Pubkey
Recognize pubkey as a noun meaning the public key of a keypair.
2018-08-09 13:41:37 -06:00

19 lines
536 B
Rust

use entry::Entry;
use hash::Hash;
use signature::Pubkey;
use transaction::{Instruction, Transaction, Vote};
pub fn entries_to_votes(entries: &[Entry]) -> Vec<(Pubkey, Vote, Hash)> {
entries
.iter()
.flat_map(|entry| entry.transactions.iter().filter_map(transaction_to_vote))
.collect()
}
pub fn transaction_to_vote(tx: &Transaction) -> Option<(Pubkey, Vote, Hash)> {
match tx.instruction {
Instruction::NewVote(ref vote) => Some((tx.from, vote.clone(), tx.last_id)),
_ => None,
}
}