Delete unused code

This commit is contained in:
Greg Fitzgerald 2019-03-24 22:12:47 -06:00 committed by Grimes
parent 6286947697
commit aefa9891c0
2 changed files with 3 additions and 54 deletions

View File

@ -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<Blob>;
fn to_single_entry_blobs(&self) -> Vec<Blob>;
fn to_single_entry_shared_blobs(&self) -> Vec<SharedBlob>;
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<Blob> {
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<Transaction>) -> Entry {
@ -415,7 +400,7 @@ pub fn make_large_test_entries(num_entries: usize) -> Vec<Entry> {
#[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 {

View File

@ -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)]
);
}
}