From f38842822f5417f2f82f5dbe5db734883311fcbb Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Tue, 3 Jul 2018 16:24:55 -0600 Subject: [PATCH] Cleanup code duplication --- src/fullnode.rs | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/fullnode.rs b/src/fullnode.rs index 41c4420ba69780..46773e0d53a442 100644 --- a/src/fullnode.rs +++ b/src/fullnode.rs @@ -84,41 +84,23 @@ impl FullNode { server } else { node.data.current_leader_id = node.data.id.clone(); - let server = match outfile_for_leader { + let outfile_for_leader: Box = match outfile_for_leader { Some(OutFile::Path(file)) => { - FullNode::new_leader( - bank, - entry_height, - //Some(Duration::from_millis(1000)), - None, - node, - exit.clone(), - File::create(file).expect("opening ledger file"), - ) - } - Some(OutFile::StdOut) => { - FullNode::new_leader( - bank, - entry_height, - //Some(Duration::from_millis(1000)), - None, - node, - exit.clone(), - stdout(), - ) - } - None => { - FullNode::new_leader( - bank, - entry_height, - //Some(Duration::from_millis(1000)), - None, - node, - exit.clone(), - sink(), - ) + Box::new(File::create(file).expect("opening ledger file")) } + Some(OutFile::StdOut) => Box::new(stdout()), + None => Box::new(sink()), }; + + let server = FullNode::new_leader( + bank, + entry_height, + //Some(Duration::from_millis(1000)), + None, + node, + exit.clone(), + outfile_for_leader, + ); info!( "leader ready... local request address: {} (advertising {})", local_requests_addr, requests_addr