From 80f07dadc513277c03cee587ec262ca74d625d1e Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Thu, 31 May 2018 10:04:56 -0600 Subject: [PATCH] Generalize process_entries() And use it in fullnode --- src/bank.rs | 5 ++++- src/bin/fullnode.rs | 12 +----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/bank.rs b/src/bank.rs index 3b2ef23c9..9dc5b6cdb 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -260,7 +260,10 @@ impl Bank { .collect() } - pub fn process_entries(&self, entries: Vec) -> Result<()> { + pub fn process_entries(&self, entries: I) -> Result<()> + where + I: IntoIterator, + { for entry in entries { self.register_entry_id(&entry.id); for result in self.process_transactions(entry.transactions) { diff --git a/src/bin/fullnode.rs b/src/bin/fullnode.rs index 3a3fec144..dcbc8f374 100644 --- a/src/bin/fullnode.rs +++ b/src/bin/fullnode.rs @@ -114,17 +114,7 @@ fn main() { bank.register_entry_id(&entry1.id); eprintln!("processing entries..."); - - for entry in entries { - let results = bank.process_transactions(entry.transactions); - for result in results { - if let Err(e) = result { - eprintln!("failed to process transaction {:?}", e); - exit(1); - } - } - bank.register_entry_id(&entry.id); - } + bank.process_entries(entries).expect("process_entries"); eprintln!("creating networking stack...");