diff --git a/src/accounting_stage.rs b/src/accounting_stage.rs index 49343ba66..6c6f7225f 100644 --- a/src/accounting_stage.rs +++ b/src/accounting_stage.rs @@ -138,13 +138,13 @@ pub enum Response { #[cfg(test)] mod tests { use accountant::Accountant; + use accounting_stage::AccountingStage; use entry::Entry; use event::Event; use historian::Historian; use mint::Mint; use signature::{KeyPair, KeyPairUtil}; use std::sync::mpsc::sync_channel; - use accounting_stage::AccountingStage; use transaction::Transaction; #[test] @@ -193,21 +193,22 @@ mod bench { extern crate test; use self::test::Bencher; use accountant::{Accountant, MAX_ENTRY_IDS}; + use accounting_stage::*; use bincode::serialize; use hash::hash; + use historian::Historian; use mint::Mint; + use rayon::prelude::*; use signature::{KeyPair, KeyPairUtil}; use std::collections::HashSet; use std::sync::mpsc::sync_channel; use std::time::Instant; - use accounting_stage::*; use transaction::Transaction; #[bench] fn process_events_bench(_bencher: &mut Bencher) { let mint = Mint::new(100_000_000); let acc = Accountant::new(&mint); - let rsp_addr: SocketAddr = "0.0.0.0:0".parse().expect("socket address"); // Create transactions between unrelated parties. let txs = 100_000; let last_ids: Mutex> = Mutex::new(HashSet::new()); @@ -239,24 +240,24 @@ mod bench { }) .collect(); - let req_vers = transactions + let events: Vec<_> = transactions .into_iter() - .map(|tr| (Request::Transaction(tr), rsp_addr, 1_u8)) + .map(|tr| Event::Transaction(tr)) .collect(); let (input, event_receiver) = sync_channel(10); let historian = Historian::new(event_receiver, &mint.last_id(), None); - let stage = AccountingStage::new(acc, input, historian); + let stage = AccountingStage::new(acc, input); let now = Instant::now(); - assert!(stage.process_events(req_vers).is_ok()); + assert!(stage.process_events(events).is_ok()); let duration = now.elapsed(); let sec = duration.as_secs() as f64 + duration.subsec_nanos() as f64 / 1_000_000_000.0; let tps = txs as f64 / sec; // Ensure that all transactions were successfully logged. drop(stage.historian_input); - let entries: Vec = stage.historian.output.lock().unwrap().iter().collect(); + let entries: Vec = historian.output.lock().unwrap().iter().collect(); assert_eq!(entries.len(), 1); assert_eq!(entries[0].events.len(), txs as usize); diff --git a/src/ecdsa.rs b/src/ecdsa.rs index 59c407caa..9a18c9600 100644 --- a/src/ecdsa.rs +++ b/src/ecdsa.rs @@ -130,11 +130,11 @@ pub fn ed25519_verify(batches: &Vec) -> Vec> { #[cfg(test)] mod tests { + use accounting_stage::Request; use bincode::serialize; use ecdsa; use packet::{Packet, Packets, SharedPackets}; use std::sync::RwLock; - use accounting_stage::Request; use transaction::test_tx; use transaction::Transaction; diff --git a/src/thin_client.rs b/src/thin_client.rs index 54027d2da..3622c155f 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -3,6 +3,7 @@ //! messages to the network directly. The binary encoding of its messages are //! unstable and may change in future releases. +use accounting_stage::{Request, Response, Subscription}; use bincode::{deserialize, serialize}; use futures::future::{ok, FutureResult}; use hash::Hash; @@ -10,7 +11,6 @@ use signature::{KeyPair, PublicKey, Signature}; use std::collections::HashMap; use std::io; use std::net::{SocketAddr, UdpSocket}; -use accounting_stage::{Request, Response, Subscription}; use transaction::Transaction; pub struct ThinClient {