solana/src/voting.rs

22 lines
621 B
Rust
Raw Normal View History

use entry::Entry;
use hash::Hash;
use signature::PublicKey;
use transaction::{Instruction, Vote};
2018-07-11 13:40:46 -07:00
pub fn entries_to_votes(entries: &[Entry]) -> Vec<(PublicKey, Vote, Hash)> {
entries
.iter()
.flat_map(|entry| {
let vs: Vec<(PublicKey, Vote, Hash)> = entry
.transactions
.iter()
2018-07-11 13:40:46 -07:00
.filter_map(|tx| match tx.instruction {
Instruction::NewVote(ref vote) => Some((tx.from, vote.clone(), tx.last_id)),
_ => None,
})
.collect();
vs
})
.collect()
}