Merge pull request #80 from garious/fix-ci

Fix CI
This commit is contained in:
Greg Fitzgerald 2018-03-26 22:13:11 -06:00 committed by GitHub
commit 2f18302d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 109 additions and 106 deletions

View File

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

View File

@ -1,24 +1,26 @@
use accountant::Accountant;
use transaction::Transaction;
use signature::PublicKey;
use hash::Hash;
use entry::Entry;
use std::net::UdpSocket;
use bincode::{deserialize, serialize};
use entry::Entry;
use hash::Hash;
use result::Result;
use streamer;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use serde_json;
use signature::PublicKey;
use std::default::Default;
use std::io::Write;
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::default::Default;
use serde_json;
use std::time::Duration;
use streamer;
use transaction::Transaction;
pub struct AccountantSkel {
pub struct AccountantSkel<W: Write + Send + 'static> {
pub acc: Accountant,
pub last_id: Hash,
pub ledger: Vec<Entry>,
writer: W,
}
#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
@ -37,20 +39,21 @@ pub enum Response {
Id { id: Hash, is_last: bool },
}
impl AccountantSkel {
pub fn new(acc: Accountant) -> Self {
impl<W: Write + Send + 'static> AccountantSkel<W> {
pub fn new(acc: Accountant, w: W) -> Self {
let last_id = acc.first_id;
AccountantSkel {
acc,
last_id,
ledger: vec![],
writer: w,
}
}
pub fn sync(self: &mut Self) -> Hash {
pub fn sync(&mut self) -> Hash {
while let Ok(entry) = self.acc.historian.receiver.try_recv() {
self.last_id = entry.id;
println!("{}", serde_json::to_string(&entry).unwrap());
write!(self.writer, "{}", serde_json::to_string(&entry).unwrap()).unwrap();
self.ledger.push(entry);
}
self.last_id
@ -131,7 +134,7 @@ impl AccountantSkel {
/// UDP Server that forwards messages to Accountant methods.
pub fn serve(
obj: Arc<Mutex<AccountantSkel>>,
obj: Arc<Mutex<AccountantSkel<W>>>,
addr: &str,
exit: Arc<AtomicBool>,
) -> Result<Vec<JoinHandle<()>>> {

View File

@ -2,14 +2,14 @@
//! event log to record transactions. Its users can deposit funds and
//! 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 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 addr: String,
@ -122,12 +122,13 @@ mod tests {
use super::*;
use accountant::Accountant;
use accountant_skel::AccountantSkel;
use std::thread::sleep;
use std::time::Duration;
use mint::Mint;
use signature::{KeyPair, KeyPairUtil};
use std::sync::{Arc, Mutex};
use std::io::sink;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Duration;
#[test]
fn test_accountant_stub() {
@ -137,9 +138,9 @@ mod tests {
let acc = Accountant::new(&alice, Some(30));
let bob_pubkey = KeyPair::new().pubkey();
let exit = Arc::new(AtomicBool::new(false));
let acc = Arc::new(Mutex::new(AccountantSkel::new(acc)));
let acc = Arc::new(Mutex::new(AccountantSkel::new(acc, sink())));
let threads = AccountantSkel::serve(acc, addr, exit.clone()).unwrap();
sleep(Duration::from_millis(30));
sleep(Duration::from_millis(300));
let socket = UdpSocket::bind(send_addr).unwrap();
let mut acc = AccountantStub::new(addr, socket);

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
extern crate serde_json;
extern crate silk;
use silk::accountant_skel::AccountantSkel;
use silk::accountant::Accountant;
use std::io::{self, BufRead};
use std::sync::{Arc, Mutex};
use silk::accountant_skel::AccountantSkel;
use std::io::{self, stdout, BufRead};
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
fn main() {
let addr = "127.0.0.1:8000";
@ -16,7 +16,7 @@ fn main() {
.map(|line| serde_json::from_str(&line.unwrap()).unwrap());
let acc = Accountant::new_from_entries(entries, Some(1000));
let exit = Arc::new(AtomicBool::new(false));
let skel = Arc::new(Mutex::new(AccountantSkel::new(acc)));
let skel = Arc::new(Mutex::new(AccountantSkel::new(acc, stdout())));
eprintln!("Listening on {}", addr);
let threads = AccountantSkel::serve(skel, addr, exit.clone()).unwrap();
for t in threads {

View File

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

View File

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

View File

@ -1,14 +1,14 @@
//! The `historian` crate provides a microservice for generating a Proof-of-History.
//! 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 hash::Hash;
use recorder::{ExitReason, Recorder, Signal};
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 sender: SyncSender<Signal>,

View File

@ -1,6 +1,7 @@
//! The `ledger` crate provides the foundational data structures for Proof-of-History,
//! 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
/// 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`
@ -12,9 +13,7 @@
/// Though processing power varies across nodes, the network gives priority to the
/// 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.
use hash::Hash;
use entry::{next_tick, Entry};
use rayon::prelude::*;
/// 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))]
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_skel;
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 signature;
pub mod streamer;
pub mod transaction;
extern crate bincode;
extern crate chrono;
extern crate generic_array;

View File

@ -1,12 +1,12 @@
//! 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::create_entry;
use event::Event;
use hash::{hash, Hash};
use ring::rand::SystemRandom;
use signature::{KeyPair, KeyPairUtil, PublicKey};
use transaction::Transaction;
use untrusted::Input;
#[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
//! `Payment`, the payment is executed.
use signature::PublicKey;
use chrono::prelude::*;
use signature::PublicKey;
use std::mem;
pub enum Witness {

View File

@ -5,12 +5,12 @@
//! Event, the latest hash, and the number of hashes since the last event.
//! 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 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))]
pub enum Signal {

View File

@ -1,7 +1,7 @@
use bincode;
use serde_json;
use std;
use std::any::Any;
use bincode;
#[derive(Debug)]
pub enum Error {
@ -62,16 +62,16 @@ impl std::convert::From<std::boxed::Box<bincode::ErrorKind>> for Error {
#[cfg(test)]
mod tests {
use result::Result;
use result::Error;
use result::Result;
use serde_json;
use std::io;
use std::io::Write;
use std::net::SocketAddr;
use std::sync::mpsc::RecvError;
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::thread;
fn addr_parse_error() -> Result<SocketAddr> {
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::mpsc;
use std::fmt;
use std::time::Duration;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::sync::{Arc, Mutex, RwLock};
use std::thread::{spawn, JoinHandle};
use result::{Error, Result};
use std::time::Duration;
const BLOCK_SIZE: usize = 1024 * 8;
pub const PACKET_SIZE: usize = 256;
@ -282,15 +282,15 @@ pub fn responder(
mod bench {
extern crate test;
use self::test::Bencher;
use std::thread::sleep;
use std::sync::{Arc, Mutex};
use result::Result;
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::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};
fn producer(
@ -381,13 +381,13 @@ mod bench {
#[cfg(test)]
mod test {
use std::sync::{Arc, Mutex};
use std::io;
use std::io::Write;
use std::net::UdpSocket;
use std::time::Duration;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::io::Write;
use std::io;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use streamer::{allocate, receiver, responder, Packet, Packets, Receiver, Response, Responses,
PACKET_SIZE};

View File

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