Rename KeyPair to Keypair

This commit is contained in:
Greg Fitzgerald 2018-08-09 08:56:04 -06:00
parent 8567253833
commit c2bbe4344e
28 changed files with 209 additions and 209 deletions

View File

@ -10,7 +10,7 @@ use rayon::prelude::*;
use solana::bank::*;
use solana::hash::hash;
use solana::mint::Mint;
use solana::signature::{KeyPair, KeyPairUtil};
use solana::signature::{Keypair, KeypairUtil};
use solana::transaction::Transaction;
fn bench_process_transaction(bencher: &mut Bencher) {
@ -22,7 +22,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {
.into_par_iter()
.map(|i| {
// Seed the 'from' account.
let rando0 = KeyPair::new();
let rando0 = Keypair::new();
let tx = Transaction::new(&mint.keypair(), rando0.pubkey(), 10_000, mint.last_id());
assert!(bank.process_transaction(&tx).is_ok());
@ -30,7 +30,7 @@ fn bench_process_transaction(bencher: &mut Bencher) {
let last_id = hash(&serialize(&i).unwrap()); // Unique hash
bank.register_entry_id(&last_id);
let rando1 = KeyPair::new();
let rando1 = Keypair::new();
let tx = Transaction::new(&rando0, rando1.pubkey(), 1, last_id);
assert!(bank.process_transaction(&tx).is_ok());

View File

@ -11,7 +11,7 @@ use solana::banking_stage::BankingStage;
use solana::mint::Mint;
use solana::packet::{to_packets_chunked, PacketRecycler};
use solana::record_stage::Signal;
use solana::signature::{KeyPair, KeyPairUtil};
use solana::signature::{Keypair, KeypairUtil};
use solana::transaction::Transaction;
use std::iter;
use std::sync::mpsc::{channel, Receiver};
@ -23,7 +23,7 @@ use std::sync::Arc;
// use hash::hash;
// use mint::Mint;
// use rayon::prelude::*;
// use signature::{KeyPair, KeyPairUtil};
// use signature::{Keypair, KeypairUtil};
// use std::collections::HashSet;
// use std::time::Instant;
// use transaction::Transaction;
@ -49,11 +49,11 @@ use std::sync::Arc;
// }
//
// // Seed the 'from' account.
// let rando0 = KeyPair::new();
// let rando0 = Keypair::new();
// let tx = Transaction::new(&mint.keypair(), rando0.pubkey(), 1_000, last_id);
// bank.process_transaction(&tx).unwrap();
//
// let rando1 = KeyPair::new();
// let rando1 = Keypair::new();
// let tx = Transaction::new(&rando0, rando1.pubkey(), 2, last_id);
// bank.process_transaction(&tx).unwrap();
//
@ -102,9 +102,9 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
let num_dst_accounts = 8 * 1024;
let num_src_accounts = 8 * 1024;
let srckeys: Vec<_> = (0..num_src_accounts).map(|_| KeyPair::new()).collect();
let srckeys: Vec<_> = (0..num_src_accounts).map(|_| Keypair::new()).collect();
let dstkeys: Vec<_> = (0..num_dst_accounts)
.map(|_| KeyPair::new().pubkey())
.map(|_| Keypair::new().pubkey())
.collect();
let transactions: Vec<_> = (0..tx)
@ -175,7 +175,7 @@ fn bench_banking_stage_single_from(bencher: &mut Bencher) {
let mut pubkeys = Vec::new();
let num_keys = 8;
for _ in 0..num_keys {
pubkeys.push(KeyPair::new().pubkey());
pubkeys.push(Keypair::new().pubkey());
}
let transactions: Vec<_> = (0..tx)

View File

@ -6,14 +6,14 @@ use criterion::{Bencher, Criterion};
use solana::hash::{hash, Hash};
use solana::ledger::{next_entries, reconstruct_entries_from_blobs, Block};
use solana::packet::BlobRecycler;
use solana::signature::{KeyPair, KeyPairUtil};
use solana::signature::{Keypair, KeypairUtil};
use solana::transaction::Transaction;
use std::collections::VecDeque;
fn bench_block_to_blobs_to_block(bencher: &mut Bencher) {
let zero = Hash::default();
let one = hash(&zero.as_ref());
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new(&keypair, keypair.pubkey(), 1, one);
let transactions = vec![tx0; 10];
let entries = next_entries(&zero, 1, transactions);

View File

@ -14,7 +14,7 @@ use ledger::Block;
use log::Level;
use mint::Mint;
use payment_plan::{Payment, PaymentPlan, Witness};
use signature::{KeyPair, PublicKey, Signature};
use signature::{Keypair, PublicKey, Signature};
use std::collections::hash_map::Entry::Occupied;
use std::collections::{HashMap, HashSet, VecDeque};
use std::result;
@ -519,7 +519,7 @@ impl Bank {
pub fn transfer(
&self,
n: i64,
keypair: &KeyPair,
keypair: &Keypair,
to: PublicKey,
last_id: Hash,
) -> Result<Signature> {
@ -534,7 +534,7 @@ impl Bank {
pub fn transfer_on_date(
&self,
n: i64,
keypair: &KeyPair,
keypair: &Keypair,
to: PublicKey,
dt: DateTime<Utc>,
last_id: Hash,
@ -580,14 +580,14 @@ mod tests {
use hash::hash;
use ledger;
use packet::BLOB_DATA_SIZE;
use signature::KeyPairUtil;
use signature::KeypairUtil;
use std::io::{BufReader, Cursor, Seek, SeekFrom};
use std::mem::size_of;
#[test]
fn test_two_payments_to_one_party() {
let mint = Mint::new(10_000);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
let bank = Bank::new(&mint);
assert_eq!(bank.last_id(), mint.last_id());
@ -604,7 +604,7 @@ mod tests {
#[test]
fn test_negative_tokens() {
let mint = Mint::new(1);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
let bank = Bank::new(&mint);
assert_eq!(
bank.transfer(-1, &mint.keypair(), pubkey, mint.last_id()),
@ -617,7 +617,7 @@ mod tests {
fn test_account_not_found() {
let mint = Mint::new(1);
let bank = Bank::new(&mint);
let keypair = KeyPair::new();
let keypair = Keypair::new();
assert_eq!(
bank.transfer(1, &keypair, mint.pubkey(), mint.last_id()),
Err(BankError::AccountNotFound(keypair.pubkey()))
@ -629,7 +629,7 @@ mod tests {
fn test_insufficient_funds() {
let mint = Mint::new(11_000);
let bank = Bank::new(&mint);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
bank.transfer(1_000, &mint.keypair(), pubkey, mint.last_id())
.unwrap();
assert_eq!(bank.transaction_count(), 1);
@ -648,7 +648,7 @@ mod tests {
fn test_transfer_to_newb() {
let mint = Mint::new(10_000);
let bank = Bank::new(&mint);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
bank.transfer(500, &mint.keypair(), pubkey, mint.last_id())
.unwrap();
assert_eq!(bank.get_balance(&pubkey), 500);
@ -658,7 +658,7 @@ mod tests {
fn test_transfer_on_date() {
let mint = Mint::new(1);
let bank = Bank::new(&mint);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
let dt = Utc::now();
bank.transfer_on_date(1, &mint.keypair(), pubkey, dt, mint.last_id())
.unwrap();
@ -690,7 +690,7 @@ mod tests {
fn test_cancel_transfer() {
let mint = Mint::new(1);
let bank = Bank::new(&mint);
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
let dt = Utc::now();
let sig = bank
.transfer_on_date(1, &mint.keypair(), pubkey, dt, mint.last_id())
@ -795,7 +795,7 @@ mod tests {
fn test_debits_before_credits() {
let mint = Mint::new(2);
let bank = Bank::new(&mint);
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new(&mint.keypair(), keypair.pubkey(), 2, mint.last_id());
let tx1 = Transaction::new(&keypair, mint.pubkey(), 1, mint.last_id());
let txs = vec![tx0, tx1];
@ -810,7 +810,7 @@ mod tests {
fn test_process_empty_entry_is_registered() {
let mint = Mint::new(1);
let bank = Bank::new(&mint);
let keypair = KeyPair::new();
let keypair = Keypair::new();
let entry = next_entry(&mint.last_id(), 1, vec![]);
let tx = Transaction::new(&mint.keypair(), keypair.pubkey(), 1, entry.id);
@ -838,7 +838,7 @@ mod tests {
mint: &Mint,
length: usize,
) -> impl Iterator<Item = Entry> {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let hash = mint.last_id();
let mut txs = Vec::with_capacity(length);
for i in 0..length {
@ -858,7 +858,7 @@ mod tests {
let mut hash = mint.last_id();
let mut num_hashes = 0;
for _ in 0..length {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx = Transaction::new(&mint.keypair(), keypair.pubkey(), 1, hash);
let entry = Entry::new_mut(&mut hash, &mut num_hashes, vec![tx], false);
entries.push(entry);

View File

@ -238,7 +238,7 @@ mod test {
//mod tests {
// use bank::Bank;
// use mint::Mint;
// use signature::{KeyPair, KeyPairUtil};
// use signature::{Keypair, KeypairUtil};
// use transaction::Transaction;
//
// #[test]
@ -253,7 +253,7 @@ mod test {
// let banking_stage = EventProcessor::new(bank, &mint.last_id(), None);
//
// // Process a batch that includes a transaction that receives two tokens.
// let alice = KeyPair::new();
// let alice = Keypair::new();
// let tx = Transaction::new(&mint.keypair(), alice.pubkey(), 2, mint.last_id());
// let transactions = vec![tx];
// let entry0 = banking_stage.process_transactions(transactions).unwrap();

View File

@ -19,7 +19,7 @@ use solana::metrics;
use solana::nat::{udp_public_bind, udp_random_bind, UdpSocketPair};
use solana::ncp::Ncp;
use solana::service::Service;
use solana::signature::{read_keypair, GenKeys, KeyPair, KeyPairUtil};
use solana::signature::{read_keypair, GenKeys, Keypair, KeypairUtil};
use solana::streamer::default_window;
use solana::thin_client::ThinClient;
use solana::timing::{duration_as_ms, duration_as_s};
@ -109,7 +109,7 @@ fn sample_tx_count(
}
/// Send loopback payment of 0 tokens and confirm the network processed it
fn send_barrier_transaction(barrier_client: &mut ThinClient, last_id: &mut Hash, id: &KeyPair) {
fn send_barrier_transaction(barrier_client: &mut ThinClient, last_id: &mut Hash, id: &Keypair) {
let transfer_start = Instant::now();
let mut poll_count = 0;
@ -172,8 +172,8 @@ fn send_barrier_transaction(barrier_client: &mut ThinClient, last_id: &mut Hash,
fn generate_txs(
shared_txs: &Arc<RwLock<VecDeque<Vec<Transaction>>>>,
id: &KeyPair,
keypairs: &[KeyPair],
id: &Keypair,
keypairs: &[Keypair],
last_id: &Hash,
threads: usize,
reclaim: bool,
@ -271,7 +271,7 @@ fn do_tx_transfers(
}
}
fn airdrop_tokens(client: &mut ThinClient, leader: &NodeInfo, id: &KeyPair, tx_count: i64) {
fn airdrop_tokens(client: &mut ThinClient, leader: &NodeInfo, id: &Keypair, tx_count: i64) {
let mut drone_addr = leader.contact_info.tpu;
drone_addr.set_port(DRONE_PORT);
@ -655,7 +655,7 @@ fn spy_node(addr: Option<String>) -> (NodeInfo, UdpSocket) {
gossip_socket_pair = udp_public_bind("gossip", 8000, 10000);
}
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
let daddr = "0.0.0.0:0".parse().unwrap();
assert!(!gossip_socket_pair.addr.ip().is_unspecified());
assert!(!gossip_socket_pair.addr.ip().is_multicast());

View File

@ -13,7 +13,7 @@ use solana::fullnode::{Config, FullNode};
use solana::logger;
use solana::metrics::set_panic_hook;
use solana::service::Service;
use solana::signature::{KeyPair, KeyPairUtil};
use solana::signature::{Keypair, KeypairUtil};
use solana::wallet::request_airdrop;
use std::fs::File;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
@ -53,7 +53,7 @@ fn main() -> () {
.get_matches();
let bind_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8000);
let mut keypair = KeyPair::new();
let mut keypair = Keypair::new();
let mut repl_data = NodeInfo::new_leader_with_pubkey(keypair.pubkey(), &bind_addr);
if let Some(i) = matches.value_of("identity") {
let path = i.to_string();

View File

@ -13,7 +13,7 @@ use solana::crdt::NodeInfo;
use solana::drone::DRONE_PORT;
use solana::fullnode::Config;
use solana::logger;
use solana::signature::{read_keypair, KeyPair, KeyPairUtil, PublicKey, Signature};
use solana::signature::{read_keypair, Keypair, KeypairUtil, PublicKey, Signature};
use solana::thin_client::ThinClient;
use solana::wallet::request_airdrop;
use std::error;
@ -56,7 +56,7 @@ impl error::Error for WalletError {
struct WalletConfig {
leader: NodeInfo,
id: KeyPair,
id: Keypair,
drone_addr: SocketAddr,
command: WalletCommand,
}
@ -66,7 +66,7 @@ impl Default for WalletConfig {
let default_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8000);
WalletConfig {
leader: NodeInfo::new_leader(&default_addr),
id: KeyPair::new(),
id: Keypair::new(),
drone_addr: default_addr,
command: WalletCommand::Balance,
}

View File

@ -118,7 +118,7 @@ impl PaymentPlan for Budget {
#[cfg(test)]
mod tests {
use super::*;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
#[test]
fn test_signature_satisfied() {
@ -160,8 +160,8 @@ mod tests {
#[test]
fn test_future_payment() {
let dt = Utc.ymd(2014, 11, 14).and_hms(8, 9, 10);
let from = KeyPair::new().pubkey();
let to = KeyPair::new().pubkey();
let from = Keypair::new().pubkey();
let to = Keypair::new().pubkey();
let mut budget = Budget::new_future_payment(dt, from, 42, to);
budget.apply_witness(&Witness::Timestamp(dt), &from);
@ -173,8 +173,8 @@ mod tests {
// Ensure timestamp will only be acknowledged if it came from the
// whitelisted public key.
let dt = Utc.ymd(2014, 11, 14).and_hms(8, 9, 10);
let from = KeyPair::new().pubkey();
let to = KeyPair::new().pubkey();
let from = Keypair::new().pubkey();
let to = Keypair::new().pubkey();
let mut budget = Budget::new_future_payment(dt, from, 42, to);
let orig_budget = budget.clone();

View File

@ -192,7 +192,7 @@ impl<'a> ChooseGossipPeerStrategy for ChooseWeightedPeerStrategy<'a> {
mod tests {
use choose_gossip_peer_strategy::{ChooseWeightedPeerStrategy, DEFAULT_WEIGHT};
use logger;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use signature::{Keypair, KeypairUtil, PublicKey};
use std;
use std::collections::HashMap;
@ -205,7 +205,7 @@ mod tests {
logger::setup();
// Initialize the filler keys
let key1 = KeyPair::new().pubkey();
let key1 = Keypair::new().pubkey();
let remote: HashMap<PublicKey, u64> = HashMap::new();
let external_liveness: HashMap<PublicKey, HashMap<PublicKey, u64>> = HashMap::new();
@ -224,8 +224,8 @@ mod tests {
logger::setup();
// Initialize the filler keys
let key1 = KeyPair::new().pubkey();
let key2 = KeyPair::new().pubkey();
let key1 = Keypair::new().pubkey();
let key2 = Keypair::new().pubkey();
let remote: HashMap<PublicKey, u64> = HashMap::new();
let mut external_liveness: HashMap<PublicKey, HashMap<PublicKey, u64>> = HashMap::new();
@ -249,8 +249,8 @@ mod tests {
logger::setup();
// Initialize the filler keys
let key1 = KeyPair::new().pubkey();
let key2 = KeyPair::new().pubkey();
let key1 = Keypair::new().pubkey();
let key2 = Keypair::new().pubkey();
let remote: HashMap<PublicKey, u64> = HashMap::new();
let mut external_liveness: HashMap<PublicKey, HashMap<PublicKey, u64>> = HashMap::new();
@ -273,7 +273,7 @@ mod tests {
logger::setup();
// Initialize the filler keys
let key1 = KeyPair::new().pubkey();
let key1 = Keypair::new().pubkey();
let mut remote: HashMap<PublicKey, u64> = HashMap::new();
let mut external_liveness: HashMap<PublicKey, HashMap<PublicKey, u64>> = HashMap::new();
@ -285,7 +285,7 @@ mod tests {
remote.insert(key1, 0);
for i in 0..num_peers {
let pk = KeyPair::new().pubkey();
let pk = Keypair::new().pubkey();
rumors.insert(pk, i);
}
@ -303,7 +303,7 @@ mod tests {
logger::setup();
// Initialize the filler keys
let key1 = KeyPair::new().pubkey();
let key1 = Keypair::new().pubkey();
let mut remote: HashMap<PublicKey, u64> = HashMap::new();
let mut external_liveness: HashMap<PublicKey, HashMap<PublicKey, u64>> = HashMap::new();
@ -316,7 +316,7 @@ mod tests {
remote.insert(key1, old_index);
for _i in 0..num_peers {
let pk = KeyPair::new().pubkey();
let pk = Keypair::new().pubkey();
rumors.insert(pk, old_index);
}

View File

@ -25,7 +25,7 @@ use pnet_datalink as datalink;
use rand::{thread_rng, RngCore};
use rayon::prelude::*;
use result::{Error, Result};
use signature::{KeyPair, KeyPairUtil, PublicKey};
use signature::{Keypair, KeypairUtil, PublicKey};
use std;
use std::collections::HashMap;
use std::collections::VecDeque;
@ -176,7 +176,7 @@ impl NodeInfo {
let addr: SocketAddr = "0.0.0.0:0".parse().unwrap();
assert!(addr.ip().is_unspecified());
Self::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
addr.clone(),
addr.clone(),
addr.clone(),
@ -190,7 +190,7 @@ impl NodeInfo {
let addr: SocketAddr = "224.0.1.255:1000".parse().unwrap();
assert!(addr.ip().is_multicast());
Self::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
addr.clone(),
addr.clone(),
addr.clone(),
@ -223,7 +223,7 @@ impl NodeInfo {
)
}
pub fn new_leader(bind_addr: &SocketAddr) -> Self {
let keypair = KeyPair::new();
let keypair = Keypair::new();
Self::new_leader_with_pubkey(keypair.pubkey(), bind_addr)
}
pub fn new_entry_point(gossip_addr: SocketAddr) -> Self {
@ -1269,7 +1269,7 @@ pub struct TestNode {
impl TestNode {
pub fn new_localhost() -> Self {
let pubkey = KeyPair::new().pubkey();
let pubkey = Keypair::new().pubkey();
Self::new_localhost_with_pubkey(pubkey)
}
pub fn new_localhost_with_pubkey(pubkey: PublicKey) -> Self {
@ -1381,7 +1381,7 @@ mod tests {
use logger;
use packet::BlobRecycler;
use result::Error;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use signature::{Keypair, KeypairUtil, PublicKey};
use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
@ -1403,7 +1403,7 @@ mod tests {
#[test]
fn test_bad_address() {
let d1 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.0:1234".parse().unwrap(),
"0.0.0.0:1235".parse().unwrap(),
"0.0.0.0:1236".parse().unwrap(),
@ -1415,7 +1415,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadGossipAddress))
);
let d1_1 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.1:1234".parse().unwrap(),
"0.0.0.0:1235".parse().unwrap(),
"0.0.0.0:1236".parse().unwrap(),
@ -1427,7 +1427,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadContactInfo))
);
let d2 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.1:0".parse().unwrap(),
"0.0.0.1:0".parse().unwrap(),
"0.0.0.1:0".parse().unwrap(),
@ -1439,7 +1439,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadGossipAddress))
);
let d2_1 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.1:1234".parse().unwrap(),
"0.0.0.1:0".parse().unwrap(),
"0.0.0.1:0".parse().unwrap(),
@ -1467,7 +1467,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadNodeInfo))
);
let d6 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.0:1234".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
@ -1479,7 +1479,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadGossipAddress))
);
let d7 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.1:0".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
@ -1491,7 +1491,7 @@ mod tests {
Some(Error::CrdtError(CrdtError::BadGossipAddress))
);
let d8 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"0.0.0.1:1234".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
"0.0.0.0:0".parse().unwrap(),
@ -1504,7 +1504,7 @@ mod tests {
#[test]
fn insert_test() {
let mut d = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1597,7 +1597,7 @@ mod tests {
}
#[test]
fn replicated_data_new_leader_with_pubkey() {
let kp = KeyPair::new();
let kp = Keypair::new();
let d1 = NodeInfo::new_leader_with_pubkey(
kp.pubkey().clone(),
&"127.0.0.1:1234".parse().unwrap(),
@ -1615,7 +1615,7 @@ mod tests {
#[test]
fn update_test() {
let d1 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1623,7 +1623,7 @@ mod tests {
"127.0.0.1:1238".parse().unwrap(),
);
let d2 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1631,7 +1631,7 @@ mod tests {
"127.0.0.1:1238".parse().unwrap(),
);
let d3 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1674,7 +1674,7 @@ mod tests {
#[test]
fn window_index_request() {
let me = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1685,7 +1685,7 @@ mod tests {
let rv = crdt.window_index_request(0);
assert_matches!(rv, Err(Error::CrdtError(CrdtError::NoPeers)));
let nxt = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1696,7 +1696,7 @@ mod tests {
let rv = crdt.window_index_request(0);
assert_matches!(rv, Err(Error::CrdtError(CrdtError::NoPeers)));
let nxt = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.2:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1709,7 +1709,7 @@ mod tests {
assert_eq!(rv.0, "127.0.0.2:1234".parse().unwrap());
let nxt = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.3:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1735,7 +1735,7 @@ mod tests {
#[test]
fn gossip_request_bad_addr() {
let me = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:127".parse().unwrap(),
"127.0.0.1:127".parse().unwrap(),
"127.0.0.1:127".parse().unwrap(),
@ -1760,7 +1760,7 @@ mod tests {
#[test]
fn gossip_request() {
let me = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1771,7 +1771,7 @@ mod tests {
let rv = crdt.gossip_request();
assert_matches!(rv, Err(Error::CrdtError(CrdtError::NoPeers)));
let nxt1 = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.2:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1894,7 +1894,7 @@ mod tests {
logger::setup();
let window = default_window();
let me = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),
@ -1917,7 +1917,7 @@ mod tests {
assert!(rv.is_none());
fn tmp_ledger(name: &str) -> String {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let path = format!("/tmp/farf/{}-{}", name, keypair.pubkey());
@ -1998,7 +1998,7 @@ mod tests {
//add a bunch of nodes with a new leader
for _ in 0..10 {
let mut dum = NodeInfo::new_entry_point("127.0.0.1:1234".parse().unwrap());
dum.id = KeyPair::new().pubkey();
dum.id = Keypair::new().pubkey();
dum.leader_id = leader1.id;
crdt.insert(&dum);
}
@ -2061,7 +2061,7 @@ mod tests {
fn test_default_leader() {
logger::setup();
let node_info = NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),

View File

@ -7,7 +7,7 @@
use influx_db_client as influxdb;
use metrics;
use signature::Signature;
use signature::{KeyPair, PublicKey};
use signature::{Keypair, PublicKey};
use std::io;
use std::io::{Error, ErrorKind};
use std::net::{IpAddr, SocketAddr, UdpSocket};
@ -28,7 +28,7 @@ pub enum DroneRequest {
}
pub struct Drone {
mint_keypair: KeyPair,
mint_keypair: Keypair,
ip_cache: Vec<IpAddr>,
_airdrop_addr: SocketAddr,
transactions_addr: SocketAddr,
@ -40,7 +40,7 @@ pub struct Drone {
impl Drone {
pub fn new(
mint_keypair: KeyPair,
mint_keypair: Keypair,
_airdrop_addr: SocketAddr,
transactions_addr: SocketAddr,
requests_addr: SocketAddr,
@ -163,7 +163,7 @@ mod tests {
use logger;
use mint::Mint;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::fs::remove_dir_all;
use std::net::{SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, Ordering};
@ -174,7 +174,7 @@ mod tests {
#[test]
fn test_check_request_limit() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
addr.set_ip(get_ip_addr().unwrap());
let transactions_addr = "0.0.0.0:0".parse().unwrap();
@ -194,7 +194,7 @@ mod tests {
#[test]
fn test_clear_request_count() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
addr.set_ip(get_ip_addr().unwrap());
let transactions_addr = "0.0.0.0:0".parse().unwrap();
@ -208,7 +208,7 @@ mod tests {
#[test]
fn test_add_ip_to_cache() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
addr.set_ip(get_ip_addr().unwrap());
let transactions_addr = "0.0.0.0:0".parse().unwrap();
@ -223,7 +223,7 @@ mod tests {
#[test]
fn test_clear_ip_cache() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
addr.set_ip(get_ip_addr().unwrap());
let transactions_addr = "0.0.0.0:0".parse().unwrap();
@ -240,7 +240,7 @@ mod tests {
#[test]
fn test_drone_default_init() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
addr.set_ip(get_ip_addr().unwrap());
let transactions_addr = "0.0.0.0:0".parse().unwrap();
@ -260,7 +260,7 @@ mod tests {
}
fn tmp_ledger_path(name: &str) -> String {
let keypair = KeyPair::new();
let keypair = Keypair::new();
format!("/tmp/tmp-ledger-{}-{}", name, keypair.pubkey())
}
@ -272,13 +272,13 @@ mod tests {
const TPS_BATCH: i64 = 5_000_000;
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let alice = Mint::new(10_000_000);
let bank = Bank::new(&alice);
let bob_pubkey = KeyPair::new().pubkey();
let carlos_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let carlos_pubkey = Keypair::new().pubkey();
let exit = Arc::new(AtomicBool::new(false));
let leader_data = leader.data.clone();
let ledger_path = tmp_ledger_path("send_airdrop");

View File

@ -219,7 +219,7 @@ mod tests {
use chrono::prelude::*;
use entry::Entry;
use hash::hash;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use transaction::Transaction;
#[test]
@ -237,7 +237,7 @@ mod tests {
let zero = Hash::default();
// First, verify entries
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new(&keypair, keypair.pubkey(), 0, zero);
let tx1 = Transaction::new(&keypair, keypair.pubkey(), 1, zero);
let mut e0 = Entry::new(&zero, 0, vec![tx0.clone(), tx1.clone()], false);
@ -254,7 +254,7 @@ mod tests {
let zero = Hash::default();
// First, verify entries
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new_timestamp(&keypair, Utc::now(), zero);
let tx1 = Transaction::new_signature(&keypair, Default::default(), zero);
let mut e0 = Entry::new(&zero, 0, vec![tx0.clone(), tx1.clone()], false);
@ -277,7 +277,7 @@ mod tests {
assert_eq!(tick.num_hashes, 0);
assert_eq!(tick.id, zero);
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new_timestamp(&keypair, Utc::now(), zero);
let entry0 = next_entry(&zero, 1, vec![tx0.clone()]);
assert_eq!(entry0.num_hashes, 1);
@ -288,7 +288,7 @@ mod tests {
#[should_panic]
fn test_next_entry_panic() {
let zero = Hash::default();
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx = Transaction::new(&keypair, keypair.pubkey(), 0, zero);
next_entry(&zero, 0, vec![tx]);
}

View File

@ -104,7 +104,7 @@ mod tests {
use ledger;
use mint::Mint;
use packet::BLOB_DATA_SIZE;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::io::Cursor;
use transaction::Transaction;
@ -115,7 +115,7 @@ mod tests {
let writer = io::sink();
let mut entry_writer = EntryWriter::new(&bank, writer);
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx = Transaction::new(&mint.keypair(), keypair.pubkey(), 1, mint.last_id());
// NOTE: if Entry grows to larger than a transaction, the code below falls over

View File

@ -599,8 +599,8 @@ mod test {
use logger;
use packet::{BlobRecycler, BLOB_HEADER_SIZE, BLOB_SIZE};
use rand::{thread_rng, Rng};
use signature::KeyPair;
use signature::KeyPairUtil;
use signature::Keypair;
use signature::KeypairUtil;
// use std::sync::{Arc, RwLock};
use streamer::{index_blobs, WindowSlot};
@ -728,7 +728,7 @@ mod test {
}
let d = crdt::NodeInfo::new(
KeyPair::new().pubkey(),
Keypair::new().pubkey(),
"127.0.0.1:1234".parse().unwrap(),
"127.0.0.1:1235".parse().unwrap(),
"127.0.0.1:1236".parse().unwrap(),

View File

@ -8,7 +8,7 @@ use ncp::Ncp;
use packet::BlobRecycler;
use rpu::Rpu;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::collections::VecDeque;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering};
@ -37,13 +37,13 @@ pub struct Config {
impl Config {
pub fn new(bind_addr: &SocketAddr, pkcs8: Vec<u8>) -> Self {
let keypair =
KeyPair::from_pkcs8(Input::from(&pkcs8)).expect("from_pkcs8 in fullnode::Config new");
Keypair::from_pkcs8(Input::from(&pkcs8)).expect("from_pkcs8 in fullnode::Config new");
let pubkey = keypair.pubkey();
let node_info = NodeInfo::new_leader_with_pubkey(pubkey, bind_addr);
Config { node_info, pkcs8 }
}
pub fn keypair(&self) -> KeyPair {
KeyPair::from_pkcs8(Input::from(&self.pkcs8))
pub fn keypair(&self) -> Keypair {
Keypair::from_pkcs8(Input::from(&self.pkcs8))
.expect("from_pkcs8 in fullnode::Config keypair")
}
}
@ -53,7 +53,7 @@ impl FullNode {
mut node: TestNode,
leader: bool,
ledger_path: &str,
keypair: KeyPair,
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
sigverify_disabled: bool,
) -> FullNode {
@ -127,7 +127,7 @@ impl FullNode {
node: TestNode,
leader: bool,
ledger: &str,
keypair: KeyPair,
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
) -> FullNode {
FullNode::new_internal(
@ -144,7 +144,7 @@ impl FullNode {
node: TestNode,
leader: bool,
ledger_path: &str,
keypair: KeyPair,
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
) -> FullNode {
FullNode::new_internal(
@ -202,7 +202,7 @@ impl FullNode {
/// `---------------------`
/// ```
pub fn new_leader(
keypair: KeyPair,
keypair: Keypair,
bank: Bank,
entry_height: u64,
ledger_tail: Option<Vec<Entry>>,
@ -292,7 +292,7 @@ impl FullNode {
/// `-------------------------------`
/// ```
pub fn new_validator(
keypair: KeyPair,
keypair: Keypair,
bank: Bank,
entry_height: u64,
ledger_tail: Option<Vec<Entry>>,
@ -376,13 +376,13 @@ mod tests {
use fullnode::FullNode;
use mint::Mint;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
#[test]
fn validator_exit() {
let kp = KeyPair::new();
let kp = Keypair::new();
let tn = TestNode::new_localhost_with_pubkey(kp.pubkey());
let alice = Mint::new(10_000);
let bank = Bank::new(&alice);
@ -396,7 +396,7 @@ mod tests {
fn validator_parallel_exit() {
let vals: Vec<FullNode> = (0..2)
.map(|_| {
let kp = KeyPair::new();
let kp = Keypair::new();
let tn = TestNode::new_localhost_with_pubkey(kp.pubkey());
let alice = Mint::new(10_000);
let bank = Bank::new(&alice);

View File

@ -508,13 +508,13 @@ mod tests {
use entry::{next_entry, Entry};
use hash::hash;
use packet::{BlobRecycler, BLOB_DATA_SIZE, PACKET_DATA_SIZE};
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use transaction::{Transaction, Vote};
fn tmp_ledger_path(name: &str) -> String {
let keypair = KeyPair::new();
let keypair = Keypair::new();
format!("/tmp/tmp-ledger-{}-{}", name, keypair.pubkey())
}
@ -538,7 +538,7 @@ mod tests {
fn make_tiny_test_entries(num: usize) -> Vec<Entry> {
let zero = Hash::default();
let one = hash(&zero.as_ref());
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mut id = one;
let mut num_hashes = 0;
@ -557,7 +557,7 @@ mod tests {
fn make_test_entries() -> Vec<Entry> {
let zero = Hash::default();
let one = hash(&zero.as_ref());
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx0 = Transaction::new_vote(
&keypair,
Vote {
@ -612,7 +612,7 @@ mod tests {
logger::setup();
let id = Hash::default();
let next_id = hash(&id.as_ref());
let keypair = KeyPair::new();
let keypair = Keypair::new();
let tx_small = Transaction::new_vote(
&keypair,
Vote {

View File

@ -3,7 +3,7 @@
use entry::Entry;
use hash::{hash, Hash};
use ring::rand::SystemRandom;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use signature::{Keypair, KeypairUtil, PublicKey};
use transaction::Transaction;
use untrusted::Input;
@ -17,7 +17,7 @@ pub struct Mint {
impl Mint {
pub fn new_with_pkcs8(tokens: i64, pkcs8: Vec<u8>) -> Self {
let keypair =
KeyPair::from_pkcs8(Input::from(&pkcs8)).expect("from_pkcs8 in mint pub fn new");
Keypair::from_pkcs8(Input::from(&pkcs8)).expect("from_pkcs8 in mint pub fn new");
let pubkey = keypair.pubkey();
Mint {
pkcs8,
@ -28,7 +28,7 @@ impl Mint {
pub fn new(tokens: i64) -> Self {
let rnd = SystemRandom::new();
let pkcs8 = KeyPair::generate_pkcs8(&rnd)
let pkcs8 = Keypair::generate_pkcs8(&rnd)
.expect("generate_pkcs8 in mint pub fn new")
.to_vec();
Self::new_with_pkcs8(tokens, pkcs8)
@ -42,8 +42,8 @@ impl Mint {
self.create_entries()[1].id
}
pub fn keypair(&self) -> KeyPair {
KeyPair::from_pkcs8(Input::from(&self.pkcs8)).expect("from_pkcs8 in mint pub fn keypair")
pub fn keypair(&self) -> Keypair {
Keypair::from_pkcs8(Input::from(&self.pkcs8)).expect("from_pkcs8 in mint pub fn keypair")
}
pub fn pubkey(&self) -> PublicKey {

View File

@ -140,7 +140,7 @@ impl Service for RecordStage {
mod tests {
use super::*;
use ledger::Block;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::sync::mpsc::channel;
use std::thread::sleep;
@ -185,8 +185,8 @@ mod tests {
let (tx_sender, signal_receiver) = channel();
let zero = Hash::default();
let (_record_stage, entry_receiver) = RecordStage::new(signal_receiver, &zero);
let alice_keypair = KeyPair::new();
let bob_pubkey = KeyPair::new().pubkey();
let alice_keypair = Keypair::new();
let bob_pubkey = Keypair::new().pubkey();
let tx0 = Transaction::new(&alice_keypair, bob_pubkey, 1, zero);
let tx1 = Transaction::new(&alice_keypair, bob_pubkey, 2, zero);
tx_sender

View File

@ -8,7 +8,7 @@ use log::Level;
use packet::BlobRecycler;
use result::{Error, Result};
use service::Service;
use signature::KeyPair;
use signature::Keypair;
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicUsize;
@ -72,7 +72,7 @@ impl ReplicateStage {
Ok(())
}
pub fn new(
keypair: KeyPair,
keypair: Keypair,
bank: Arc<Bank>,
crdt: Arc<RwLock<Crdt>>,
blob_recycler: BlobRecycler,

View File

@ -13,7 +13,7 @@ use std::fmt;
use std::fs::File;
use untrusted::Input;
pub type KeyPair = Ed25519KeyPair;
pub type Keypair = Ed25519KeyPair;
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PublicKey(GenericArray<u8, U32>);
@ -74,12 +74,12 @@ impl fmt::Display for Signature {
}
}
pub trait KeyPairUtil {
pub trait KeypairUtil {
fn new() -> Self;
fn pubkey(&self) -> PublicKey;
}
impl KeyPairUtil for Ed25519KeyPair {
impl KeypairUtil for Ed25519KeyPair {
/// Return a new ED25519 keypair
fn new() -> Self {
let rng = rand::SystemRandom::new();
@ -113,10 +113,10 @@ impl GenKeys {
(0..n).map(|_| self.gen_seed()).collect()
}
pub fn gen_n_keypairs(&mut self, n: i64) -> Vec<KeyPair> {
pub fn gen_n_keypairs(&mut self, n: i64) -> Vec<Keypair> {
self.gen_n_seeds(n)
.into_par_iter()
.map(|seed| KeyPair::from_seed_unchecked(Input::from(&seed)).unwrap())
.map(|seed| Keypair::from_seed_unchecked(Input::from(&seed)).unwrap())
.collect()
}
}
@ -127,7 +127,7 @@ pub fn read_pkcs8(path: &str) -> Result<Vec<u8>, Box<error::Error>> {
Ok(pkcs8)
}
pub fn read_keypair(path: &str) -> Result<KeyPair, Box<error::Error>> {
pub fn read_keypair(path: &str) -> Result<Keypair, Box<error::Error>> {
let pkcs8 = read_pkcs8(path)?;
let keypair = Ed25519KeyPair::from_pkcs8(Input::from(&pkcs8))?;
Ok(keypair)

View File

@ -6,7 +6,7 @@
use bincode::{deserialize, serialize};
use hash::Hash;
use request::{Request, Response};
use signature::{KeyPair, PublicKey, Signature};
use signature::{Keypair, PublicKey, Signature};
use std::collections::HashMap;
use std::io;
use std::net::{SocketAddr, UdpSocket};
@ -99,7 +99,7 @@ impl ThinClient {
pub fn transfer(
&self,
n: i64,
keypair: &KeyPair,
keypair: &Keypair,
to: PublicKey,
last_id: &Hash,
) -> io::Result<Signature> {
@ -289,14 +289,14 @@ mod tests {
use logger;
use mint::Mint;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use transaction::{Instruction, Plan};
fn tmp_ledger(name: &str, mint: &Mint) -> String {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let path = format!("/tmp/tmp-ledger-{}-{}", name, keypair.pubkey());
@ -309,13 +309,13 @@ mod tests {
#[test]
fn test_thin_client() {
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_data = leader.data.clone();
let alice = Mint::new(10_000);
let bank = Bank::new(&alice);
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let exit = Arc::new(AtomicBool::new(false));
let ledger_path = tmp_ledger("thin_client", &alice);
@ -358,11 +358,11 @@ mod tests {
#[ignore]
fn test_bad_sig() {
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let alice = Mint::new(10_000);
let bank = Bank::new(&alice);
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let exit = Arc::new(AtomicBool::new(false));
let leader_data = leader.data.clone();
let ledger_path = tmp_ledger("bad_sig", &alice);
@ -418,11 +418,11 @@ mod tests {
#[test]
fn test_client_check_signature() {
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let alice = Mint::new(10_000);
let bank = Bank::new(&alice);
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let exit = Arc::new(AtomicBool::new(false));
let leader_data = leader.data.clone();
let ledger_path = tmp_ledger("client_check_signature", &alice);

View File

@ -32,7 +32,7 @@ use fetch_stage::FetchStage;
use packet::{BlobRecycler, PacketRecycler};
use record_stage::RecordStage;
use service::Service;
use signature::KeyPair;
use signature::Keypair;
use sigverify_stage::SigVerifyStage;
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
@ -52,7 +52,7 @@ pub struct Tpu {
impl Tpu {
pub fn new(
keypair: KeyPair,
keypair: Keypair,
bank: &Arc<Bank>,
crdt: &Arc<RwLock<Crdt>>,
tick_duration: Option<Duration>,

View File

@ -5,7 +5,7 @@ use budget::{Budget, Condition};
use chrono::prelude::*;
use hash::Hash;
use payment_plan::{Payment, PaymentPlan, Witness};
use signature::{KeyPair, KeyPairUtil, PublicKey, Signature};
use signature::{Keypair, KeypairUtil, PublicKey, Signature};
pub const SIGNED_DATA_OFFSET: usize = 112;
pub const SIG_OFFSET: usize = 8;
@ -97,7 +97,7 @@ pub struct Transaction {
impl Transaction {
/// Create a signed transaction from the given `Instruction`.
fn new_from_instruction(
from_keypair: &KeyPair,
from_keypair: &Keypair,
instruction: Instruction,
last_id: Hash,
fee: i64,
@ -116,7 +116,7 @@ impl Transaction {
/// Create and sign a new Transaction. Used for unit-testing.
pub fn new_taxed(
from_keypair: &KeyPair,
from_keypair: &Keypair,
to: PublicKey,
tokens: i64,
fee: i64,
@ -133,29 +133,29 @@ impl Transaction {
}
/// Create and sign a new Transaction. Used for unit-testing.
pub fn new(from_keypair: &KeyPair, to: PublicKey, tokens: i64, last_id: Hash) -> Self {
pub fn new(from_keypair: &Keypair, to: PublicKey, tokens: i64, last_id: Hash) -> Self {
Self::new_taxed(from_keypair, to, tokens, 0, last_id)
}
/// Create and sign a new Witness Timestamp. Used for unit-testing.
pub fn new_timestamp(from_keypair: &KeyPair, dt: DateTime<Utc>, last_id: Hash) -> Self {
pub fn new_timestamp(from_keypair: &Keypair, dt: DateTime<Utc>, last_id: Hash) -> Self {
let instruction = Instruction::ApplyTimestamp(dt);
Self::new_from_instruction(from_keypair, instruction, last_id, 0)
}
/// Create and sign a new Witness Signature. Used for unit-testing.
pub fn new_signature(from_keypair: &KeyPair, tx_sig: Signature, last_id: Hash) -> Self {
pub fn new_signature(from_keypair: &Keypair, tx_sig: Signature, last_id: Hash) -> Self {
let instruction = Instruction::ApplySignature(tx_sig);
Self::new_from_instruction(from_keypair, instruction, last_id, 0)
}
pub fn new_vote(from_keypair: &KeyPair, vote: Vote, last_id: Hash, fee: i64) -> Self {
pub fn new_vote(from_keypair: &Keypair, vote: Vote, last_id: Hash, fee: i64) -> Self {
Transaction::new_from_instruction(&from_keypair, Instruction::NewVote(vote), last_id, fee)
}
/// Create and sign a postdated Transaction. Used for unit-testing.
pub fn new_on_date(
from_keypair: &KeyPair,
from_keypair: &Keypair,
to: PublicKey,
dt: DateTime<Utc>,
tokens: i64,
@ -184,7 +184,7 @@ impl Transaction {
}
/// Sign this transaction.
pub fn sign(&mut self, keypair: &KeyPair) {
pub fn sign(&mut self, keypair: &Keypair) {
let sign_data = self.get_sign_data();
self.sig = Signature::new(keypair.sign(&sign_data).as_ref());
}
@ -208,7 +208,7 @@ impl Transaction {
}
pub fn test_tx() -> Transaction {
let keypair1 = KeyPair::new();
let keypair1 = Keypair::new();
let pubkey1 = keypair1.pubkey();
let zero = Hash::default();
Transaction::new(&keypair1, pubkey1, 42, zero)
@ -233,7 +233,7 @@ mod tests {
#[test]
fn test_claim() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let zero = Hash::default();
let tx0 = Transaction::new(&keypair, keypair.pubkey(), 42, zero);
assert!(tx0.verify_plan());
@ -242,8 +242,8 @@ mod tests {
#[test]
fn test_transfer() {
let zero = Hash::default();
let keypair0 = KeyPair::new();
let keypair1 = KeyPair::new();
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let pubkey1 = keypair1.pubkey();
let tx0 = Transaction::new(&keypair0, pubkey1, 42, zero);
assert!(tx0.verify_plan());
@ -252,8 +252,8 @@ mod tests {
#[test]
fn test_transfer_with_fee() {
let zero = Hash::default();
let keypair0 = KeyPair::new();
let pubkey1 = KeyPair::new().pubkey();
let keypair0 = Keypair::new();
let pubkey1 = Keypair::new().pubkey();
assert!(Transaction::new_taxed(&keypair0, pubkey1, 1, 1, zero).verify_plan());
assert!(!Transaction::new_taxed(&keypair0, pubkey1, 1, 2, zero).verify_plan());
assert!(!Transaction::new_taxed(&keypair0, pubkey1, 1, -1, zero).verify_plan());
@ -282,7 +282,7 @@ mod tests {
#[test]
fn test_token_attack() {
let zero = Hash::default();
let keypair = KeyPair::new();
let keypair = Keypair::new();
let pubkey = keypair.pubkey();
let mut tx = Transaction::new(&keypair, pubkey, 42, zero);
if let Instruction::NewContract(contract) = &mut tx.instruction {
@ -297,9 +297,9 @@ mod tests {
#[test]
fn test_hijack_attack() {
let keypair0 = KeyPair::new();
let keypair1 = KeyPair::new();
let thief_keypair = KeyPair::new();
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let thief_keypair = Keypair::new();
let pubkey1 = keypair1.pubkey();
let zero = Hash::default();
let mut tx = Transaction::new(&keypair0, pubkey1, 42, zero);
@ -323,8 +323,8 @@ mod tests {
#[test]
fn test_overspend_attack() {
let keypair0 = KeyPair::new();
let keypair1 = KeyPair::new();
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let zero = Hash::default();
let mut tx = Transaction::new(&keypair0, keypair1.pubkey(), 1, zero);
if let Instruction::NewContract(contract) = &mut tx.instruction {

View File

@ -42,7 +42,7 @@ use crdt::Crdt;
use packet::BlobRecycler;
use replicate_stage::ReplicateStage;
use service::Service;
use signature::KeyPair;
use signature::Keypair;
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, RwLock};
@ -70,7 +70,7 @@ impl Tvu {
/// * `exit` - The exit signal.
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new(
keypair: KeyPair,
keypair: Keypair,
bank: &Arc<Bank>,
entry_height: u64,
crdt: Arc<RwLock<Crdt>>,
@ -152,7 +152,7 @@ pub mod tests {
use packet::BlobRecycler;
use result::Result;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::collections::VecDeque;
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
@ -179,7 +179,7 @@ pub mod tests {
fn test_replicate() {
logger::setup();
let leader = TestNode::new_localhost();
let target1_keypair = KeyPair::new();
let target1_keypair = Keypair::new();
let target1 = TestNode::new_localhost_with_pubkey(target1_keypair.pubkey());
let target2 = TestNode::new_localhost();
let exit = Arc::new(AtomicBool::new(false));
@ -252,7 +252,7 @@ pub mod tests {
let mut blob_id = 0;
let num_transfers = 10;
let transfer_amount = 501;
let bob_keypair = KeyPair::new();
let bob_keypair = Keypair::new();
for i in 0..num_transfers {
let entry0 = Entry::new(&cur_hash, i, vec![], false);
bank.register_entry_id(&cur_hash);

View File

@ -11,7 +11,7 @@ use metrics;
use packet::{BlobRecycler, SharedBlob};
use result::Result;
use service::Service;
use signature::KeyPair;
use signature::Keypair;
use std::collections::VecDeque;
use std::result;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
@ -35,7 +35,7 @@ enum VoteError {
pub fn create_vote_tx_and_blob(
last_id: &Hash,
keypair: &KeyPair,
keypair: &Keypair,
crdt: &Arc<RwLock<Crdt>>,
blob_recycler: &BlobRecycler,
) -> Result<(Transaction, SharedBlob)> {
@ -114,7 +114,7 @@ fn get_last_id_to_vote_on(
pub fn send_leader_vote(
debug_id: u64,
keypair: &KeyPair,
keypair: &Keypair,
bank: &Arc<Bank>,
crdt: &Arc<RwLock<Crdt>>,
blob_recycler: &BlobRecycler,
@ -166,7 +166,7 @@ pub fn send_leader_vote(
fn send_validator_vote(
bank: &Arc<Bank>,
keypair: &Arc<KeyPair>,
keypair: &Arc<Keypair>,
crdt: &Arc<RwLock<Crdt>>,
blob_recycler: &BlobRecycler,
vote_blob_sender: &BlobSender,
@ -182,7 +182,7 @@ fn send_validator_vote(
impl VoteStage {
pub fn new(
keypair: Arc<KeyPair>,
keypair: Arc<Keypair>,
bank: Arc<Bank>,
crdt: Arc<RwLock<Crdt>>,
blob_recycler: BlobRecycler,
@ -203,7 +203,7 @@ impl VoteStage {
}
fn run(
keypair: &Arc<KeyPair>,
keypair: &Arc<Keypair>,
bank: &Arc<Bank>,
crdt: &Arc<RwLock<Crdt>>,
blob_recycler: &BlobRecycler,
@ -243,7 +243,7 @@ pub mod tests {
use mint::Mint;
use packet::BlobRecycler;
use service::Service;
use signature::{KeyPair, KeyPairUtil};
use signature::{Keypair, KeypairUtil};
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
@ -252,7 +252,7 @@ pub mod tests {
/// Ensure the VoteStage issues votes at the expected cadence
#[test]
fn test_vote_cadence() {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let mint = Mint::new(1234);
let bank = Arc::new(Bank::new(&mint));

View File

@ -11,7 +11,7 @@ use log::Level;
use packet::BlobRecycler;
use result::{Error, Result};
use service::Service;
use signature::KeyPair;
use signature::Keypair;
use std::collections::VecDeque;
use std::net::UdpSocket;
use std::sync::atomic::AtomicUsize;
@ -69,7 +69,7 @@ impl WriteStage {
/// Create a new WriteStage for writing and broadcasting entries.
pub fn new(
keypair: KeyPair,
keypair: Keypair,
bank: Arc<Bank>,
crdt: Arc<RwLock<Crdt>>,
blob_recycler: BlobRecycler,

View File

@ -15,7 +15,7 @@ use solana::mint::Mint;
use solana::ncp::Ncp;
use solana::result;
use solana::service::Service;
use solana::signature::{KeyPair, KeyPairUtil, PublicKey};
use solana::signature::{Keypair, KeypairUtil, PublicKey};
use solana::streamer::{default_window, WINDOW_SIZE};
use solana::thin_client::ThinClient;
use solana::timing::duration_as_s;
@ -79,7 +79,7 @@ fn converge(leader: &NodeInfo, num_nodes: usize) -> Vec<NodeInfo> {
}
fn tmp_ledger_path(name: &str) -> String {
let keypair = KeyPair::new();
let keypair = Keypair::new();
format!("/tmp/tmp-ledger-{}-{}", name, keypair.pubkey())
}
@ -123,11 +123,11 @@ fn make_tiny_test_entries(start_hash: Hash, num: usize) -> Vec<Entry> {
fn test_multi_node_ledger_window() -> result::Result<()> {
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader_pubkey = leader_keypair.pubkey().clone();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_data = leader.data.clone();
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let mut ledger_paths = Vec::new();
let (alice, leader_ledger_path) = genesis("multi_node_ledger_window", 10_000);
@ -155,7 +155,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
// start up another validator from zero, converge and then check
// balances
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let validator_data = validator.data.clone();
let validator = FullNode::new(
@ -203,11 +203,11 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
logger::setup();
const N: usize = 5;
trace!("test_multi_node_validator_catchup_from_zero");
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader_pubkey = leader_keypair.pubkey().clone();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_data = leader.data.clone();
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let mut ledger_paths = Vec::new();
let (alice, leader_ledger_path) = genesis("multi_node_validator_catchup_from_zero", 10_000);
@ -228,7 +228,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
let mut nodes = vec![server];
for _ in 0..N {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let ledger_path = tmp_copy_ledger(
&leader_ledger_path,
@ -269,7 +269,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
success = 0;
// start up another validator from zero, converge and then check everyone's
// balances
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let val = FullNode::new(
validator,
@ -327,11 +327,11 @@ fn test_multi_node_basic() {
logger::setup();
const N: usize = 5;
trace!("test_multi_node_basic");
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader_pubkey = leader_keypair.pubkey().clone();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_data = leader.data.clone();
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let mut ledger_paths = Vec::new();
let (alice, leader_ledger_path) = genesis("multi_node_basic", 10_000);
@ -345,7 +345,7 @@ fn test_multi_node_basic() {
let mut nodes = vec![server];
for _ in 0..N {
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let ledger_path = tmp_copy_ledger(&leader_ledger_path, "multi_node_basic");
ledger_paths.push(ledger_path.clone());
@ -389,9 +389,9 @@ fn test_multi_node_basic() {
#[test]
fn test_boot_validator_from_file() -> result::Result<()> {
logger::setup();
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let (alice, leader_ledger_path) = genesis("boot_validator_from_file", 100_000);
let mut ledger_paths = Vec::new();
ledger_paths.push(leader_ledger_path.clone());
@ -405,7 +405,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(1000)).unwrap();
assert_eq!(leader_balance, 1000);
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let validator_data = validator.data.clone();
let ledger_path = tmp_copy_ledger(&leader_ledger_path, "boot_validator_from_file");
@ -431,7 +431,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
}
fn create_leader(ledger_path: &str) -> (NodeInfo, FullNode) {
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let leader_data = leader.data.clone();
let leader_fullnode = FullNode::new(leader, true, &ledger_path, leader_keypair, None);
@ -446,7 +446,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
logger::setup();
let (alice, ledger_path) = genesis("leader_restart_validator_start_from_old_ledger", 100_000);
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let (leader_data, leader_fullnode) = create_leader(&ledger_path);
@ -475,7 +475,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
let (leader_data, leader_fullnode) = create_leader(&ledger_path);
// start validator from old ledger
let keypair = KeyPair::new();
let keypair = Keypair::new();
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
let validator_data = validator.data.clone();
@ -535,10 +535,10 @@ fn test_multi_node_dynamic_network() {
Err(_) => std::usize::MAX,
};
let leader_keypair = KeyPair::new();
let leader_keypair = Keypair::new();
let leader_pubkey = leader_keypair.pubkey().clone();
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
let bob_pubkey = KeyPair::new().pubkey();
let bob_pubkey = Keypair::new().pubkey();
let (alice, leader_ledger_path) = genesis("multi_node_dynamic_network", 10_000_000);
let mut ledger_paths = Vec::new();
@ -584,7 +584,7 @@ fn test_multi_node_dynamic_network() {
.name("keypair-thread".to_string())
.spawn(move || {
info!("Spawned thread {}", n);
let keypair = KeyPair::new();
let keypair = Keypair::new();
//send some tokens to the new validator
let bal = retry_send_tx_and_retry_get_balance(
&leader_data,