Finally, genesis block generation without channels
This commit is contained in:
		@@ -8,7 +8,7 @@
 | 
			
		||||
use std::collections::HashSet;
 | 
			
		||||
use std::sync::mpsc::{Receiver, SyncSender, TryRecvError};
 | 
			
		||||
use std::time::{Duration, Instant};
 | 
			
		||||
use log::{extend_and_hash, Entry, Sha256Hash};
 | 
			
		||||
use log::{create_entry_mut, Entry, Sha256Hash};
 | 
			
		||||
use event::{get_signature, verify_event, Event, Signature};
 | 
			
		||||
use serde::Serialize;
 | 
			
		||||
use std::fmt::Debug;
 | 
			
		||||
@@ -59,19 +59,10 @@ impl<T: Serialize + Clone + Debug> Logger<T> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn log_event(&mut self, event: Event<T>) -> Result<(), (Entry<T>, ExitReason)> {
 | 
			
		||||
        if let Some(sig) = get_signature(&event) {
 | 
			
		||||
            self.last_id = extend_and_hash(&self.last_id, &sig);
 | 
			
		||||
            self.num_hashes += 1;
 | 
			
		||||
        }
 | 
			
		||||
        let entry = Entry {
 | 
			
		||||
            id: self.last_id,
 | 
			
		||||
            num_hashes: self.num_hashes,
 | 
			
		||||
            event,
 | 
			
		||||
        };
 | 
			
		||||
        let entry = create_entry_mut(&mut self.last_id, &mut self.num_hashes, event);
 | 
			
		||||
        if let Err(_) = self.sender.send(entry.clone()) {
 | 
			
		||||
            return Err((entry, ExitReason::SendDisconnected));
 | 
			
		||||
        }
 | 
			
		||||
        self.num_hashes = 0;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user