Nightly rustfmt

Format code with the nightly version of rustfmt, which sorts imports.
This commit is contained in:
Greg Fitzgerald 2018-03-26 22:03:26 -06:00
parent c64a9fb456
commit ddb21d151d
18 changed files with 98 additions and 99 deletions

View File

@ -2,20 +2,20 @@
//! event log to record transactions. Its users can deposit funds and //! event log to record transactions. Its users can deposit funds and
//! transfer funds to other users. //! transfer funds to other users.
use hash::Hash; use chrono::prelude::*;
use entry::Entry; use entry::Entry;
use event::Event; use event::Event;
use plan::{Plan, Witness}; use hash::Hash;
use transaction::Transaction;
use signature::{KeyPair, PublicKey, Signature};
use mint::Mint;
use historian::Historian; use historian::Historian;
use mint::Mint;
use plan::{Plan, Witness};
use recorder::Signal; use recorder::Signal;
use std::sync::mpsc::SendError; use signature::{KeyPair, PublicKey, Signature};
use std::collections::{HashMap, HashSet};
use std::collections::hash_map::Entry::Occupied; use std::collections::hash_map::Entry::Occupied;
use std::collections::{HashMap, HashSet};
use std::result; use std::result;
use chrono::prelude::*; use std::sync::mpsc::SendError;
use transaction::Transaction;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum AccountingError { pub enum AccountingError {
@ -223,8 +223,8 @@ impl Accountant {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use signature::KeyPairUtil;
use recorder::ExitReason; use recorder::ExitReason;
use signature::KeyPairUtil;
#[test] #[test]
fn test_accountant() { fn test_accountant() {

View File

@ -1,20 +1,20 @@
use accountant::Accountant; use accountant::Accountant;
use transaction::Transaction;
use signature::PublicKey;
use hash::Hash;
use entry::Entry;
use std::net::UdpSocket;
use bincode::{deserialize, serialize}; use bincode::{deserialize, serialize};
use entry::Entry;
use hash::Hash;
use result::Result; use result::Result;
use streamer; use serde_json;
use std::sync::{Arc, Mutex}; use signature::PublicKey;
use std::time::Duration;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::thread::{spawn, JoinHandle};
use std::default::Default; use std::default::Default;
use std::io::Write; use std::io::Write;
use serde_json; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, Mutex};
use std::thread::{spawn, JoinHandle};
use std::time::Duration;
use streamer;
use transaction::Transaction;
pub struct AccountantSkel<W: Write + Send + 'static> { pub struct AccountantSkel<W: Write + Send + 'static> {
pub acc: Accountant, pub acc: Accountant,

View File

@ -2,14 +2,14 @@
//! event log to record transactions. Its users can deposit funds and //! event log to record transactions. Its users can deposit funds and
//! transfer funds to other users. //! transfer funds to other users.
use std::net::UdpSocket;
use std::io;
use bincode::{deserialize, serialize};
use transaction::Transaction;
use signature::{KeyPair, PublicKey, Signature};
use hash::Hash;
use entry::Entry;
use accountant_skel::{Request, Response}; use accountant_skel::{Request, Response};
use bincode::{deserialize, serialize};
use entry::Entry;
use hash::Hash;
use signature::{KeyPair, PublicKey, Signature};
use std::io;
use std::net::UdpSocket;
use transaction::Transaction;
pub struct AccountantStub { pub struct AccountantStub {
pub addr: String, pub addr: String,
@ -122,13 +122,13 @@ mod tests {
use super::*; use super::*;
use accountant::Accountant; use accountant::Accountant;
use accountant_skel::AccountantSkel; use accountant_skel::AccountantSkel;
use std::thread::sleep;
use std::time::Duration;
use mint::Mint; use mint::Mint;
use signature::{KeyPair, KeyPairUtil}; use signature::{KeyPair, KeyPairUtil};
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::io::sink; use std::io::sink;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Duration;
#[test] #[test]
fn test_accountant_stub() { fn test_accountant_stub() {

View File

@ -2,12 +2,12 @@ extern crate serde_json;
extern crate silk; extern crate silk;
use silk::accountant_stub::AccountantStub; use silk::accountant_stub::AccountantStub;
use silk::mint::Mint;
use silk::signature::{KeyPair, KeyPairUtil}; use silk::signature::{KeyPair, KeyPairUtil};
use silk::transaction::Transaction; use silk::transaction::Transaction;
use silk::mint::Mint;
use std::time::Instant;
use std::net::UdpSocket;
use std::io::stdin; use std::io::stdin;
use std::net::UdpSocket;
use std::time::Instant;
fn main() { fn main() {
let addr = "127.0.0.1:8000"; let addr = "127.0.0.1:8000";

View File

@ -1,12 +1,12 @@
extern crate serde_json; extern crate serde_json;
extern crate silk; extern crate silk;
use silk::mint::Mint;
use silk::event::Event;
use silk::transaction::Transaction;
use silk::entry::create_entry; use silk::entry::create_entry;
use silk::signature::{KeyPair, KeyPairUtil, PublicKey}; use silk::event::Event;
use silk::hash::Hash; use silk::hash::Hash;
use silk::mint::Mint;
use silk::signature::{KeyPair, KeyPairUtil, PublicKey};
use silk::transaction::Transaction;
use std::io::stdin; use std::io::stdin;
fn transfer(from: &KeyPair, (to, tokens): (PublicKey, i64), last_id: Hash) -> Event { fn transfer(from: &KeyPair, (to, tokens): (PublicKey, i64), last_id: Hash) -> Event {

View File

@ -1,16 +1,16 @@
extern crate silk; extern crate silk;
use silk::historian::Historian;
use silk::hash::Hash;
use silk::entry::Entry; use silk::entry::Entry;
use silk::event::Event;
use silk::hash::Hash;
use silk::historian::Historian;
use silk::ledger::verify_slice; use silk::ledger::verify_slice;
use silk::recorder::Signal; use silk::recorder::Signal;
use silk::signature::{KeyPair, KeyPairUtil}; use silk::signature::{KeyPair, KeyPairUtil};
use silk::transaction::Transaction; use silk::transaction::Transaction;
use silk::event::Event; use std::sync::mpsc::SendError;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use std::sync::mpsc::SendError;
fn create_ledger(hist: &Historian, seed: &Hash) -> Result<(), SendError<Signal>> { fn create_ledger(hist: &Historian, seed: &Hash) -> Result<(), SendError<Signal>> {
sleep(Duration::from_millis(15)); sleep(Duration::from_millis(15));

View File

@ -1,11 +1,11 @@
extern crate serde_json; extern crate serde_json;
extern crate silk; extern crate silk;
use silk::accountant_skel::AccountantSkel;
use silk::accountant::Accountant; use silk::accountant::Accountant;
use silk::accountant_skel::AccountantSkel;
use std::io::{self, stdout, BufRead}; use std::io::{self, stdout, BufRead};
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
fn main() { fn main() {
let addr = "127.0.0.1:8000"; let addr = "127.0.0.1:8000";

View File

@ -1,5 +1,5 @@
use hash::{extend_and_hash, hash, Hash};
use event::Event; use event::Event;
use hash::{extend_and_hash, hash, Hash};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Entry { pub struct Entry {
@ -87,11 +87,11 @@ pub fn next_tick(start_hash: &Hash, num_hashes: u64) -> Entry {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use entry::create_entry;
use event::Event;
use hash::hash; use hash::hash;
use signature::{KeyPair, KeyPairUtil}; use signature::{KeyPair, KeyPairUtil};
use transaction::Transaction; use transaction::Transaction;
use event::Event;
use entry::create_entry;
#[test] #[test]
fn test_entry_verify() { fn test_entry_verify() {

View File

@ -1,9 +1,9 @@
//! The `event` crate provides the data structures for log events. //! The `event` crate provides the data structures for log events.
use bincode::serialize;
use chrono::prelude::*;
use signature::{KeyPair, KeyPairUtil, PublicKey, Signature, SignatureUtil}; use signature::{KeyPair, KeyPairUtil, PublicKey, Signature, SignatureUtil};
use transaction::Transaction; use transaction::Transaction;
use chrono::prelude::*;
use bincode::serialize;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Event { pub enum Event {

View File

@ -1,14 +1,14 @@
//! The `historian` crate provides a microservice for generating a Proof-of-History. //! The `historian` crate provides a microservice for generating a Proof-of-History.
//! It manages a thread containing a Proof-of-History Logger. //! It manages a thread containing a Proof-of-History Logger.
use std::thread::{spawn, JoinHandle};
use std::collections::HashSet;
use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
use std::time::Instant;
use hash::Hash;
use entry::Entry; use entry::Entry;
use hash::Hash;
use recorder::{ExitReason, Recorder, Signal}; use recorder::{ExitReason, Recorder, Signal};
use signature::Signature; use signature::Signature;
use std::collections::HashSet;
use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
use std::thread::{spawn, JoinHandle};
use std::time::Instant;
pub struct Historian { pub struct Historian {
pub sender: SyncSender<Signal>, pub sender: SyncSender<Signal>,

View File

@ -1,6 +1,7 @@
//! The `ledger` crate provides the foundational data structures for Proof-of-History, //! The `ledger` crate provides the foundational data structures for Proof-of-History,
//! an ordered log of events in time. //! an ordered log of events in time.
use entry::{next_tick, Entry};
/// Each entry contains three pieces of data. The `num_hashes` field is the number /// Each entry contains three pieces of data. The `num_hashes` field is the number
/// of hashes performed since the previous entry. The `id` field is the result /// of hashes performed since the previous entry. The `id` field is the result
/// of hashing `id` from the previous entry `num_hashes` times. The `event` /// of hashing `id` from the previous entry `num_hashes` times. The `event`
@ -12,9 +13,7 @@
/// Though processing power varies across nodes, the network gives priority to the /// Though processing power varies across nodes, the network gives priority to the
/// fastest processor. Duration should therefore be estimated by assuming that the hash /// fastest processor. Duration should therefore be estimated by assuming that the hash
/// was generated by the fastest processor at the time the entry was recorded. /// was generated by the fastest processor at the time the entry was recorded.
use hash::Hash; use hash::Hash;
use entry::{next_tick, Entry};
use rayon::prelude::*; use rayon::prelude::*;
/// Verifies the hashes and counts of a slice of events are all consistent. /// Verifies the hashes and counts of a slice of events are all consistent.

View File

@ -1,19 +1,19 @@
#![cfg_attr(feature = "unstable", feature(test))] #![cfg_attr(feature = "unstable", feature(test))]
pub mod signature;
pub mod hash;
pub mod plan;
pub mod transaction;
pub mod event;
pub mod entry;
pub mod ledger;
pub mod mint;
pub mod recorder;
pub mod historian;
pub mod streamer;
pub mod accountant; pub mod accountant;
pub mod accountant_skel; pub mod accountant_skel;
pub mod accountant_stub; pub mod accountant_stub;
pub mod entry;
pub mod event;
pub mod hash;
pub mod historian;
pub mod ledger;
pub mod mint;
pub mod plan;
pub mod recorder;
pub mod result; pub mod result;
pub mod signature;
pub mod streamer;
pub mod transaction;
extern crate bincode; extern crate bincode;
extern crate chrono; extern crate chrono;
extern crate generic_array; extern crate generic_array;

View File

@ -1,12 +1,12 @@
//! A library for generating the chain's genesis block. //! A library for generating the chain's genesis block.
use event::Event;
use transaction::Transaction;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use entry::Entry; use entry::Entry;
use entry::create_entry; use entry::create_entry;
use event::Event;
use hash::{hash, Hash}; use hash::{hash, Hash};
use ring::rand::SystemRandom; use ring::rand::SystemRandom;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use transaction::Transaction;
use untrusted::Input; use untrusted::Input;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View File

@ -3,8 +3,8 @@
//! which it uses to reduce the payment plan. When the plan is reduced to a //! which it uses to reduce the payment plan. When the plan is reduced to a
//! `Payment`, the payment is executed. //! `Payment`, the payment is executed.
use signature::PublicKey;
use chrono::prelude::*; use chrono::prelude::*;
use signature::PublicKey;
use std::mem; use std::mem;
pub enum Witness { pub enum Witness {

View File

@ -5,12 +5,12 @@
//! Event, the latest hash, and the number of hashes since the last event. //! Event, the latest hash, and the number of hashes since the last event.
//! The resulting stream of entries represents ordered events in time. //! The resulting stream of entries represents ordered events in time.
use std::sync::mpsc::{Receiver, SyncSender, TryRecvError};
use std::time::{Duration, Instant};
use std::mem;
use hash::{hash, Hash};
use entry::{create_entry_mut, Entry}; use entry::{create_entry_mut, Entry};
use event::Event; use event::Event;
use hash::{hash, Hash};
use std::mem;
use std::sync::mpsc::{Receiver, SyncSender, TryRecvError};
use std::time::{Duration, Instant};
#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))] #[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
pub enum Signal { pub enum Signal {

View File

@ -1,7 +1,7 @@
use bincode;
use serde_json; use serde_json;
use std; use std;
use std::any::Any; use std::any::Any;
use bincode;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@ -62,16 +62,16 @@ impl std::convert::From<std::boxed::Box<bincode::ErrorKind>> for Error {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use result::Result;
use result::Error; use result::Error;
use result::Result;
use serde_json;
use std::io;
use std::io::Write;
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::mpsc::RecvError; use std::sync::mpsc::RecvError;
use std::sync::mpsc::RecvTimeoutError; use std::sync::mpsc::RecvTimeoutError;
use std::thread;
use std::io;
use std::io::Write;
use serde_json;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::thread;
fn addr_parse_error() -> Result<SocketAddr> { fn addr_parse_error() -> Result<SocketAddr> {
let r = "12fdfasfsafsadfs".parse()?; let r = "12fdfasfsafsadfs".parse()?;

View File

@ -1,11 +1,11 @@
use std::sync::{Arc, Mutex, RwLock}; use result::{Error, Result};
use std::fmt;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc; use std::sync::mpsc;
use std::fmt; use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::thread::{spawn, JoinHandle}; use std::thread::{spawn, JoinHandle};
use result::{Error, Result}; use std::time::Duration;
const BLOCK_SIZE: usize = 1024 * 8; const BLOCK_SIZE: usize = 1024 * 8;
pub const PACKET_SIZE: usize = 256; pub const PACKET_SIZE: usize = 256;
@ -282,15 +282,15 @@ pub fn responder(
mod bench { mod bench {
extern crate test; extern crate test;
use self::test::Bencher; use self::test::Bencher;
use std::thread::sleep; use result::Result;
use std::sync::{Arc, Mutex};
use std::net::{SocketAddr, UdpSocket}; use std::net::{SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::thread::{spawn, JoinHandle};
use std::time::Duration; use std::time::Duration;
use std::time::SystemTime; use std::time::SystemTime;
use std::thread::{spawn, JoinHandle};
use std::sync::mpsc::channel;
use std::sync::atomic::{AtomicBool, Ordering};
use result::Result;
use streamer::{allocate, receiver, recycle, Packet, PacketRecycler, Receiver, PACKET_SIZE}; use streamer::{allocate, receiver, recycle, Packet, PacketRecycler, Receiver, PACKET_SIZE};
fn producer( fn producer(
@ -381,13 +381,13 @@ mod bench {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::sync::{Arc, Mutex}; use std::io;
use std::io::Write;
use std::net::UdpSocket; use std::net::UdpSocket;
use std::time::Duration;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::io::Write; use std::sync::{Arc, Mutex};
use std::io; use std::time::Duration;
use streamer::{allocate, receiver, responder, Packet, Packets, Receiver, Response, Responses, use streamer::{allocate, receiver, responder, Packet, Packets, Receiver, Response, Responses,
PACKET_SIZE}; PACKET_SIZE};

View File

@ -1,10 +1,10 @@
//! The `transaction` crate provides functionality for creating log transactions. //! The `transaction` crate provides functionality for creating log transactions.
use signature::{KeyPair, KeyPairUtil, PublicKey, Signature, SignatureUtil};
use bincode::serialize; use bincode::serialize;
use hash::Hash;
use chrono::prelude::*; use chrono::prelude::*;
use hash::Hash;
use plan::{Condition, Payment, Plan}; use plan::{Condition, Payment, Plan};
use signature::{KeyPair, KeyPairUtil, PublicKey, Signature, SignatureUtil};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Transaction { pub struct Transaction {