diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 46d2518e20..a81a2568c2 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -19,6 +19,7 @@ pub mod timing; pub mod token_program; pub mod transaction; pub mod vote_program; +pub mod vote_transaction; extern crate bincode; extern crate bs58; diff --git a/src/vote_transaction.rs b/sdk/src/vote_transaction.rs similarity index 70% rename from src/vote_transaction.rs rename to sdk/src/vote_transaction.rs index d0d4d8b447..9f916303f3 100644 --- a/src/vote_transaction.rs +++ b/sdk/src/vote_transaction.rs @@ -1,19 +1,13 @@ //! The `vote_transaction` module provides functionality for creating vote transactions. -#[cfg(test)] -use bank::Bank; use bincode::deserialize; -#[cfg(test)] -use result::Result; -use solana_sdk::hash::Hash; -use solana_sdk::pubkey::Pubkey; -use solana_sdk::signature::Keypair; -#[cfg(test)] -use solana_sdk::signature::KeypairUtil; -use solana_sdk::system_instruction::SystemInstruction; -use solana_sdk::system_program; -use solana_sdk::transaction::{Instruction, Transaction}; -use solana_sdk::vote_program::{self, Vote, VoteInstruction}; +use hash::Hash; +use pubkey::Pubkey; +use signature::Keypair; +use system_instruction::SystemInstruction; +use system_program; +use transaction::{Instruction, Transaction}; +use vote_program::{self, Vote, VoteInstruction}; pub trait VoteTransaction { fn vote_new(vote_account: &Keypair, vote: Vote, last_id: Hash, fee: u64) -> Self; @@ -82,28 +76,3 @@ impl VoteTransaction for Transaction { votes } } - -#[cfg(test)] -pub fn create_vote_account( - node_keypair: &Keypair, - bank: &Bank, - num_tokens: u64, - last_id: Hash, -) -> Result { - let new_vote_account = Keypair::new(); - - // Create and register the new vote account - let tx = Transaction::vote_account_new( - node_keypair, - new_vote_account.pubkey(), - last_id, - num_tokens, - 0, - ); - bank.process_transaction(&tx)?; - - Ok(new_vote_account) -} - -#[cfg(test)] -mod tests {} diff --git a/src/bin/fullnode.rs b/src/bin/fullnode.rs index b5db1a72b6..9d144e3982 100644 --- a/src/bin/fullnode.rs +++ b/src/bin/fullnode.rs @@ -17,9 +17,9 @@ use solana::leader_scheduler::LeaderScheduler; use solana::logger; use solana::netutil::find_available_port_in_range; use solana::thin_client::poll_gossip_for_leader; -use solana::vote_transaction::VoteTransaction; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::vote_program::VoteProgram; +use solana_sdk::vote_transaction::VoteTransaction; use std::fs::File; use std::net::{Ipv4Addr, SocketAddr}; use std::process::exit; diff --git a/src/compute_leader_finality_service.rs b/src/compute_leader_finality_service.rs index 48ac28ad4f..d4047b4f48 100644 --- a/src/compute_leader_finality_service.rs +++ b/src/compute_leader_finality_service.rs @@ -7,13 +7,13 @@ use bank::Bank; use service::Service; use solana_metrics::{influxdb, submit}; use solana_sdk::timing; +use solana_sdk::vote_program::{self, VoteProgram}; use std::result; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread::sleep; use std::thread::{self, Builder, JoinHandle}; use std::time::Duration; -use solana_sdk::vote_program::{self, VoteProgram}; #[derive(Debug, PartialEq, Eq)] pub enum FinalityError { @@ -136,16 +136,17 @@ pub mod tests { use bank::Bank; use bincode::serialize; use compute_leader_finality_service::ComputeLeaderFinalityService; + use create_vote_account::*; use logger; use mint::Mint; use solana_sdk::hash::hash; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; + use solana_sdk::vote_program::Vote; + use solana_sdk::vote_transaction::VoteTransaction; use std::sync::Arc; use std::thread::sleep; use std::time::Duration; - use solana_sdk::vote_program::Vote; - use vote_transaction::{create_vote_account, VoteTransaction}; #[test] fn test_compute_finality() { diff --git a/src/create_vote_account.rs b/src/create_vote_account.rs new file mode 100644 index 0000000000..9d98002943 --- /dev/null +++ b/src/create_vote_account.rs @@ -0,0 +1,27 @@ +use bank::Bank; +use result::Result; +use solana_sdk::hash::Hash; +use solana_sdk::signature::{Keypair, KeypairUtil}; +use solana_sdk::transaction::Transaction; +use solana_sdk::vote_transaction::*; + +pub fn create_vote_account( + node_keypair: &Keypair, + bank: &Bank, + num_tokens: u64, + last_id: Hash, +) -> Result { + let new_vote_account = Keypair::new(); + + // Create and register the new vote account + let tx = Transaction::vote_account_new( + node_keypair, + new_vote_account.pubkey(), + last_id, + num_tokens, + 0, + ); + bank.process_transaction(&tx)?; + + Ok(new_vote_account) +} diff --git a/src/leader_scheduler.rs b/src/leader_scheduler.rs index 096e551084..0329384cf5 100644 --- a/src/leader_scheduler.rs +++ b/src/leader_scheduler.rs @@ -11,11 +11,11 @@ use solana_sdk::hash::{hash, Hash}; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; +use solana_sdk::vote_program::{self, Vote, VoteProgram}; +use solana_sdk::vote_transaction::VoteTransaction; use std::collections::HashSet; use std::io::Cursor; use system_transaction::SystemTransaction; -use solana_sdk::vote_program::{self, Vote, VoteProgram}; -use vote_transaction::VoteTransaction; pub const DEFAULT_BOOTSTRAP_HEIGHT: u64 = 1000; pub const DEFAULT_LEADER_ROTATION_INTERVAL: u64 = 100; @@ -506,6 +506,7 @@ pub fn make_active_set_entries( #[cfg(test)] mod tests { use bank::Bank; + use create_vote_account::*; use leader_scheduler::{ LeaderScheduler, LeaderSchedulerConfig, DEFAULT_BOOTSTRAP_HEIGHT, DEFAULT_LEADER_ROTATION_INTERVAL, DEFAULT_SEED_ROTATION_INTERVAL, @@ -515,11 +516,11 @@ mod tests { use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::transaction::Transaction; + use solana_sdk::vote_program::Vote; + use solana_sdk::vote_transaction::VoteTransaction; use std::collections::HashSet; use std::hash::Hash as StdHash; use std::iter::FromIterator; - use solana_sdk::vote_program::Vote; - use vote_transaction::{create_vote_account, VoteTransaction}; fn to_hashset_owned(slice: &[T]) -> HashSet where diff --git a/src/ledger.rs b/src/ledger.rs index 70e44f266a..28b3fa7c40 100644 --- a/src/ledger.rs +++ b/src/ledger.rs @@ -21,7 +21,7 @@ use std::io::{self, BufReader, BufWriter, Seek, SeekFrom}; use std::mem::size_of; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::Path; -use vote_transaction::VoteTransaction; +use solana_sdk::vote_transaction::VoteTransaction; // // A persistent ledger is 2 files: diff --git a/src/lib.rs b/src/lib.rs index 2a5c76035a..e3cdb0463f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,7 @@ pub mod crds_gossip_pull; pub mod crds_gossip_push; pub mod crds_traits_impls; pub mod crds_value; +pub mod create_vote_account; #[macro_use] pub mod contact_info; pub mod cluster_info; @@ -72,7 +73,6 @@ pub mod tpu; pub mod tpu_forwarder; pub mod tvu; pub mod vote_stage; -pub mod vote_transaction; pub mod wallet; pub mod window; pub mod window_service; diff --git a/src/storage_stage.rs b/src/storage_stage.rs index 96d85aab44..526b293405 100644 --- a/src/storage_stage.rs +++ b/src/storage_stage.rs @@ -279,7 +279,7 @@ mod tests { use storage_stage::NUM_IDENTITIES; use storage_stage::{get_identity_index_from_pubkey, StorageStage}; use solana_sdk::vote_program::Vote; - use vote_transaction::VoteTransaction; + use solana_sdk::vote_transaction::VoteTransaction; #[test] fn test_storage_stage_none_ledger() { diff --git a/src/thin_client.rs b/src/thin_client.rs index 46a2dc5a02..da3eb21fb5 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -440,7 +440,7 @@ mod tests { use solana_sdk::system_instruction::SystemInstruction; use std::fs::remove_dir_all; use solana_sdk::vote_program::VoteProgram; - use vote_transaction::VoteTransaction; + use solana_sdk::vote_transaction::VoteTransaction; #[test] fn test_thin_client() { diff --git a/src/vote_stage.rs b/src/vote_stage.rs index 3a035ee31d..fc1e23d04c 100644 --- a/src/vote_stage.rs +++ b/src/vote_stage.rs @@ -15,7 +15,7 @@ use std::sync::atomic::AtomicUsize; use std::sync::{Arc, RwLock}; use streamer::BlobSender; use solana_sdk::vote_program::Vote; -use vote_transaction::VoteTransaction; +use solana_sdk::vote_transaction::VoteTransaction; #[derive(Debug, PartialEq, Eq)] pub enum VoteError {