From aefa9891c02cda4d3550130ca3af422edc803625 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Sun, 24 Mar 2019 22:12:47 -0600 Subject: [PATCH] Delete unused code --- core/src/entry.rs | 18 ++--------- programs/vote_api/src/vote_transaction.rs | 39 +---------------------- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/core/src/entry.rs b/core/src/entry.rs index ef51e88c2..6a806036b 100644 --- a/core/src/entry.rs +++ b/core/src/entry.rs @@ -10,11 +10,8 @@ use chrono::prelude::Utc; use rayon::prelude::*; use solana_budget_api::budget_instruction::BudgetInstruction; use solana_sdk::hash::Hash; -use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; -use solana_vote_api::vote_instruction::Vote; -use solana_vote_api::vote_transaction::VoteTransaction; use std::borrow::Borrow; use std::mem::size_of; use std::sync::mpsc::{Receiver, Sender}; @@ -209,7 +206,6 @@ pub trait EntrySlice { fn to_blobs(&self) -> Vec; fn to_single_entry_blobs(&self) -> Vec; fn to_single_entry_shared_blobs(&self) -> Vec; - fn votes(&self) -> Vec<(Pubkey, Vote, Hash)>; } impl EntrySlice for [Entry] { @@ -260,17 +256,6 @@ impl EntrySlice for [Entry] { fn to_single_entry_blobs(&self) -> Vec { self.iter().map(|entry| entry.to_blob()).collect() } - - fn votes(&self) -> Vec<(Pubkey, Vote, Hash)> { - self.iter() - .flat_map(|entry| { - entry - .transactions - .iter() - .flat_map(VoteTransaction::get_votes) - }) - .collect() - } } pub fn next_entry_mut(start: &mut Hash, num_hashes: u64, transactions: Vec) -> Entry { @@ -415,7 +400,7 @@ pub fn make_large_test_entries(num_entries: usize) -> Vec { #[cfg(test)] pub fn make_consecutive_blobs( - id: &Pubkey, + id: &solana_sdk::pubkey::Pubkey, num_blobs_to_make: u64, start_height: u64, start_hash: Hash, @@ -455,6 +440,7 @@ mod tests { use solana_sdk::hash::hash; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::system_transaction::SystemTransaction; + use solana_vote_api::vote_transaction::VoteTransaction; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; fn create_sample_payment(keypair: &Keypair, hash: Hash) -> Transaction { diff --git a/programs/vote_api/src/vote_transaction.rs b/programs/vote_api/src/vote_transaction.rs index 02f65c8fc..f2c576df4 100644 --- a/programs/vote_api/src/vote_transaction.rs +++ b/programs/vote_api/src/vote_transaction.rs @@ -1,9 +1,8 @@ //! The `vote_transaction` module provides functionality for creating vote transactions. +use crate::id; use crate::vote_instruction::{Vote, VoteInstruction}; use crate::vote_state::VoteState; -use crate::{check_id, id}; -use bincode::deserialize; use solana_sdk::hash::Hash; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; @@ -93,40 +92,4 @@ impl VoteTransaction { tx.sign(&[vote_keypair], recent_blockhash); tx } - - fn get_vote(tx: &Transaction, ix_index: usize) -> Option<(Pubkey, Vote, Hash)> { - if !check_id(&tx.program_id(ix_index)) { - return None; - } - let instruction = deserialize(&tx.data(ix_index)).unwrap(); - if let VoteInstruction::Vote(vote) = instruction { - Some((tx.account_keys[0], vote, tx.recent_blockhash)) - } else { - None - } - } - - pub fn get_votes(tx: &Transaction) -> Vec<(Pubkey, Vote, Hash)> { - (0..tx.instructions.len()) - .filter_map(|i| Self::get_vote(tx, i)) - .collect() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_get_votes() { - let keypair = Keypair::new(); - let slot = 1; - let recent_blockhash = Hash::default(); - let transaction = - VoteTransaction::new_vote(&keypair.pubkey(), &keypair, slot, recent_blockhash, 0); - assert_eq!( - VoteTransaction::get_votes(&transaction), - vec![(keypair.pubkey(), Vote::new(slot), recent_blockhash)] - ); - } }