log -> ledger
Free up namespace for traditional runtime logs.
This commit is contained in:
@ -3,7 +3,7 @@ extern crate silk;
|
|||||||
use silk::historian::Historian;
|
use silk::historian::Historian;
|
||||||
use silk::hash::Hash;
|
use silk::hash::Hash;
|
||||||
use silk::entry::Entry;
|
use silk::entry::Entry;
|
||||||
use silk::log::verify_slice;
|
use silk::ledger::verify_slice;
|
||||||
use silk::logger::Signal;
|
use silk::logger::Signal;
|
||||||
use silk::signature::{KeyPair, KeyPairUtil};
|
use silk::signature::{KeyPair, KeyPairUtil};
|
||||||
use silk::transaction::Transaction;
|
use silk::transaction::Transaction;
|
||||||
@ -12,7 +12,7 @@ use std::thread::sleep;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::sync::mpsc::SendError;
|
use std::sync::mpsc::SendError;
|
||||||
|
|
||||||
fn create_log(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));
|
||||||
let keypair = KeyPair::new();
|
let keypair = KeyPair::new();
|
||||||
let tr = Transaction::new(&keypair, keypair.pubkey(), 42, *seed);
|
let tr = Transaction::new(&keypair, keypair.pubkey(), 42, *seed);
|
||||||
@ -25,7 +25,7 @@ fn create_log(hist: &Historian, seed: &Hash) -> Result<(), SendError<Signal>> {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let seed = Hash::default();
|
let seed = Hash::default();
|
||||||
let hist = Historian::new(&seed, Some(10));
|
let hist = Historian::new(&seed, Some(10));
|
||||||
create_log(&hist, &seed).expect("send error");
|
create_ledger(&hist, &seed).expect("send error");
|
||||||
drop(hist.sender);
|
drop(hist.sender);
|
||||||
let entries: Vec<Entry> = hist.receiver.iter().collect();
|
let entries: Vec<Entry> = hist.receiver.iter().collect();
|
||||||
for entry in &entries {
|
for entry in &entries {
|
||||||
|
@ -67,7 +67,7 @@ pub fn reserve_signature(sigs: &mut HashSet<Signature>, sig: &Signature) -> bool
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use log::*;
|
use ledger::*;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ mod tests {
|
|||||||
assert_eq!(entries.len(), 1);
|
assert_eq!(entries.len(), 1);
|
||||||
|
|
||||||
// Ensure the ID is not the seed, which indicates another Tick
|
// Ensure the ID is not the seed, which indicates another Tick
|
||||||
// was logged before the one we sent.
|
// was recorded before the one we sent.
|
||||||
assert_ne!(entries[0].id, zero);
|
assert_ne!(entries[0].id, zero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! The `log` 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.
|
||||||
|
|
||||||
/// Each log 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'
|
||||||
/// field points to an Event that took place shortly after 'id' was generated.
|
/// field points to an Event that took place shortly after 'id' was generated.
|
||||||
@ -11,7 +11,7 @@
|
|||||||
/// over time, one should expect the duration 'num_hashes' represents to decrease proportionally.
|
/// over time, one should expect the duration 'num_hashes' represents to decrease proportionally.
|
||||||
/// 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 logged.
|
/// 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 entry::{next_tick, Entry};
|
||||||
@ -60,7 +60,7 @@ mod tests {
|
|||||||
mod bench {
|
mod bench {
|
||||||
extern crate test;
|
extern crate test;
|
||||||
use self::test::Bencher;
|
use self::test::Bencher;
|
||||||
use log::*;
|
use ledger::*;
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn event_bench(bencher: &mut Bencher) {
|
fn event_bench(bencher: &mut Bencher) {
|
@ -5,7 +5,7 @@ pub mod plan;
|
|||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod entry;
|
pub mod entry;
|
||||||
pub mod log;
|
pub mod ledger;
|
||||||
pub mod mint;
|
pub mod mint;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod historian;
|
pub mod historian;
|
||||||
|
@ -57,7 +57,7 @@ impl Mint {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use log::verify_slice;
|
use ledger::verify_slice;
|
||||||
use plan::{Action, Plan};
|
use plan::{Action, Plan};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Reference in New Issue
Block a user