27 lines
753 B
Rust
27 lines
753 B
Rust
extern crate silk;
|
|
|
|
use silk::historian::Historian;
|
|
use silk::log::{verify_slice, Entry, Event, Sha256Hash};
|
|
use std::thread::sleep;
|
|
use std::time::Duration;
|
|
use std::sync::mpsc::SendError;
|
|
|
|
fn create_log(hist: &Historian) -> Result<(), SendError<Event>> {
|
|
sleep(Duration::from_millis(15));
|
|
hist.sender.send(Event::UserDataKey(Sha256Hash::default()))?;
|
|
sleep(Duration::from_millis(10));
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {
|
|
let seed = Sha256Hash::default();
|
|
let hist = Historian::new(&seed, Some(10));
|
|
create_log(&hist).expect("send error");
|
|
drop(hist.sender);
|
|
let entries: Vec<Entry> = hist.receiver.iter().collect();
|
|
for entry in &entries {
|
|
println!("{:?}", entry);
|
|
}
|
|
assert!(verify_slice(&entries, &seed));
|
|
}
|