Move vote_transaction out of src/
This commit is contained in:
parent
9ee858a00c
commit
7af95eadcc
|
@ -19,6 +19,7 @@ pub mod timing;
|
||||||
pub mod token_program;
|
pub mod token_program;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
pub mod vote_program;
|
pub mod vote_program;
|
||||||
|
pub mod vote_transaction;
|
||||||
|
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
extern crate bs58;
|
extern crate bs58;
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
//! The `vote_transaction` module provides functionality for creating vote transactions.
|
//! The `vote_transaction` module provides functionality for creating vote transactions.
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
use bank::Bank;
|
|
||||||
use bincode::deserialize;
|
use bincode::deserialize;
|
||||||
#[cfg(test)]
|
use hash::Hash;
|
||||||
use result::Result;
|
use pubkey::Pubkey;
|
||||||
use solana_sdk::hash::Hash;
|
use signature::Keypair;
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use system_instruction::SystemInstruction;
|
||||||
use solana_sdk::signature::Keypair;
|
use system_program;
|
||||||
#[cfg(test)]
|
use transaction::{Instruction, Transaction};
|
||||||
use solana_sdk::signature::KeypairUtil;
|
use vote_program::{self, Vote, VoteInstruction};
|
||||||
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};
|
|
||||||
|
|
||||||
pub trait VoteTransaction {
|
pub trait VoteTransaction {
|
||||||
fn vote_new(vote_account: &Keypair, vote: Vote, last_id: Hash, fee: u64) -> Self;
|
fn vote_new(vote_account: &Keypair, vote: Vote, last_id: Hash, fee: u64) -> Self;
|
||||||
|
@ -82,28 +76,3 @@ impl VoteTransaction for Transaction {
|
||||||
votes
|
votes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn create_vote_account(
|
|
||||||
node_keypair: &Keypair,
|
|
||||||
bank: &Bank,
|
|
||||||
num_tokens: u64,
|
|
||||||
last_id: Hash,
|
|
||||||
) -> Result<Keypair> {
|
|
||||||
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 {}
|
|
|
@ -17,9 +17,9 @@ use solana::leader_scheduler::LeaderScheduler;
|
||||||
use solana::logger;
|
use solana::logger;
|
||||||
use solana::netutil::find_available_port_in_range;
|
use solana::netutil::find_available_port_in_range;
|
||||||
use solana::thin_client::poll_gossip_for_leader;
|
use solana::thin_client::poll_gossip_for_leader;
|
||||||
use solana::vote_transaction::VoteTransaction;
|
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::vote_program::VoteProgram;
|
use solana_sdk::vote_program::VoteProgram;
|
||||||
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::net::{Ipv4Addr, SocketAddr};
|
use std::net::{Ipv4Addr, SocketAddr};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
|
@ -7,13 +7,13 @@ use bank::Bank;
|
||||||
use service::Service;
|
use service::Service;
|
||||||
use solana_metrics::{influxdb, submit};
|
use solana_metrics::{influxdb, submit};
|
||||||
use solana_sdk::timing;
|
use solana_sdk::timing;
|
||||||
|
use solana_sdk::vote_program::{self, VoteProgram};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::thread::{self, Builder, JoinHandle};
|
use std::thread::{self, Builder, JoinHandle};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use solana_sdk::vote_program::{self, VoteProgram};
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum FinalityError {
|
pub enum FinalityError {
|
||||||
|
@ -136,16 +136,17 @@ pub mod tests {
|
||||||
use bank::Bank;
|
use bank::Bank;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use compute_leader_finality_service::ComputeLeaderFinalityService;
|
use compute_leader_finality_service::ComputeLeaderFinalityService;
|
||||||
|
use create_vote_account::*;
|
||||||
use logger;
|
use logger;
|
||||||
use mint::Mint;
|
use mint::Mint;
|
||||||
use solana_sdk::hash::hash;
|
use solana_sdk::hash::hash;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::transaction::Transaction;
|
use solana_sdk::transaction::Transaction;
|
||||||
|
use solana_sdk::vote_program::Vote;
|
||||||
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use solana_sdk::vote_program::Vote;
|
|
||||||
use vote_transaction::{create_vote_account, VoteTransaction};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_compute_finality() {
|
fn test_compute_finality() {
|
||||||
|
|
|
@ -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<Keypair> {
|
||||||
|
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)
|
||||||
|
}
|
|
@ -11,11 +11,11 @@ use solana_sdk::hash::{hash, Hash};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::transaction::Transaction;
|
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::collections::HashSet;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use system_transaction::SystemTransaction;
|
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_BOOTSTRAP_HEIGHT: u64 = 1000;
|
||||||
pub const DEFAULT_LEADER_ROTATION_INTERVAL: u64 = 100;
|
pub const DEFAULT_LEADER_ROTATION_INTERVAL: u64 = 100;
|
||||||
|
@ -506,6 +506,7 @@ pub fn make_active_set_entries(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use bank::Bank;
|
use bank::Bank;
|
||||||
|
use create_vote_account::*;
|
||||||
use leader_scheduler::{
|
use leader_scheduler::{
|
||||||
LeaderScheduler, LeaderSchedulerConfig, DEFAULT_BOOTSTRAP_HEIGHT,
|
LeaderScheduler, LeaderSchedulerConfig, DEFAULT_BOOTSTRAP_HEIGHT,
|
||||||
DEFAULT_LEADER_ROTATION_INTERVAL, DEFAULT_SEED_ROTATION_INTERVAL,
|
DEFAULT_LEADER_ROTATION_INTERVAL, DEFAULT_SEED_ROTATION_INTERVAL,
|
||||||
|
@ -515,11 +516,11 @@ mod tests {
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||||
use solana_sdk::transaction::Transaction;
|
use solana_sdk::transaction::Transaction;
|
||||||
|
use solana_sdk::vote_program::Vote;
|
||||||
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::hash::Hash as StdHash;
|
use std::hash::Hash as StdHash;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use solana_sdk::vote_program::Vote;
|
|
||||||
use vote_transaction::{create_vote_account, VoteTransaction};
|
|
||||||
|
|
||||||
fn to_hashset_owned<T>(slice: &[T]) -> HashSet<T>
|
fn to_hashset_owned<T>(slice: &[T]) -> HashSet<T>
|
||||||
where
|
where
|
||||||
|
|
|
@ -21,7 +21,7 @@ use std::io::{self, BufReader, BufWriter, Seek, SeekFrom};
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use vote_transaction::VoteTransaction;
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
|
|
||||||
//
|
//
|
||||||
// A persistent ledger is 2 files:
|
// A persistent ledger is 2 files:
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub mod crds_gossip_pull;
|
||||||
pub mod crds_gossip_push;
|
pub mod crds_gossip_push;
|
||||||
pub mod crds_traits_impls;
|
pub mod crds_traits_impls;
|
||||||
pub mod crds_value;
|
pub mod crds_value;
|
||||||
|
pub mod create_vote_account;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod contact_info;
|
pub mod contact_info;
|
||||||
pub mod cluster_info;
|
pub mod cluster_info;
|
||||||
|
@ -72,7 +73,6 @@ pub mod tpu;
|
||||||
pub mod tpu_forwarder;
|
pub mod tpu_forwarder;
|
||||||
pub mod tvu;
|
pub mod tvu;
|
||||||
pub mod vote_stage;
|
pub mod vote_stage;
|
||||||
pub mod vote_transaction;
|
|
||||||
pub mod wallet;
|
pub mod wallet;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod window_service;
|
pub mod window_service;
|
||||||
|
|
|
@ -279,7 +279,7 @@ mod tests {
|
||||||
use storage_stage::NUM_IDENTITIES;
|
use storage_stage::NUM_IDENTITIES;
|
||||||
use storage_stage::{get_identity_index_from_pubkey, StorageStage};
|
use storage_stage::{get_identity_index_from_pubkey, StorageStage};
|
||||||
use solana_sdk::vote_program::Vote;
|
use solana_sdk::vote_program::Vote;
|
||||||
use vote_transaction::VoteTransaction;
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_storage_stage_none_ledger() {
|
fn test_storage_stage_none_ledger() {
|
||||||
|
|
|
@ -440,7 +440,7 @@ mod tests {
|
||||||
use solana_sdk::system_instruction::SystemInstruction;
|
use solana_sdk::system_instruction::SystemInstruction;
|
||||||
use std::fs::remove_dir_all;
|
use std::fs::remove_dir_all;
|
||||||
use solana_sdk::vote_program::VoteProgram;
|
use solana_sdk::vote_program::VoteProgram;
|
||||||
use vote_transaction::VoteTransaction;
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_thin_client() {
|
fn test_thin_client() {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::sync::atomic::AtomicUsize;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use streamer::BlobSender;
|
use streamer::BlobSender;
|
||||||
use solana_sdk::vote_program::Vote;
|
use solana_sdk::vote_program::Vote;
|
||||||
use vote_transaction::VoteTransaction;
|
use solana_sdk::vote_transaction::VoteTransaction;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum VoteError {
|
pub enum VoteError {
|
||||||
|
|
Loading…
Reference in New Issue