From a148454376b0c1387ab305a64b6fc743b03f4c2e Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 2 Mar 2018 12:07:05 -0700 Subject: [PATCH] Update readme --- README.md | 14 ++++++++------ src/bin/demo.rs | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 57a0f0e5c..62b451a7a 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,18 @@ with by verifying each entry's hash can be generated from the hash in the previo extern crate silk; use silk::historian::Historian; -use silk::log::{verify_slice, Entry, Event, Sha256Hash}; +use silk::log::{verify_slice, Entry, Sha256Hash}; +use silk::event::{generate_keypair, get_pubkey, sign_claim_data, Event}; use std::thread::sleep; use std::time::Duration; use std::sync::mpsc::SendError; -fn create_log(hist: &Historian) -> Result<(), SendError> { +fn create_log(hist: &Historian) -> Result<(), SendError>> { sleep(Duration::from_millis(15)); let data = Sha256Hash::default(); - hist.sender.send(Event::Claim { data })?; + let keypair = generate_keypair(); + let event0 = Event::new_claim(get_pubkey(&keypair), data, sign_claim_data(&data, &keypair)); + hist.sender.send(event0)?; sleep(Duration::from_millis(10)); Ok(()) } @@ -55,11 +58,10 @@ fn main() { let hist = Historian::new(&seed, Some(10)); create_log(&hist).expect("send error"); drop(hist.sender); - let entries: Vec = hist.receiver.iter().collect(); + let entries: Vec> = hist.receiver.iter().collect(); for entry in &entries { println!("{:?}", entry); } - // Proof-of-History: Verify the historian learned about the events // in the same order they appear in the vector. assert!(verify_slice(&entries, &seed)); @@ -70,7 +72,7 @@ Running the program should produce a log similar to: ```rust Entry { num_hashes: 0, end_hash: [0, ...], event: Tick } -Entry { num_hashes: 2, end_hash: [67, ...], event: Claim { data: [37, ...] } } +Entry { num_hashes: 2, end_hash: [67, ...], event: Transaction { data: [37, ...] } } Entry { num_hashes: 3, end_hash: [123, ...], event: Tick } ``` diff --git a/src/bin/demo.rs b/src/bin/demo.rs index 4d9e12000..c4b212169 100644 --- a/src/bin/demo.rs +++ b/src/bin/demo.rs @@ -26,5 +26,7 @@ fn main() { for entry in &entries { println!("{:?}", entry); } + // Proof-of-History: Verify the historian learned about the events + // in the same order they appear in the vector. assert!(verify_slice(&entries, &seed)); }