This commit is contained in:
Rob Walker
2018-07-12 16:09:58 -07:00
parent aaf6ce5aea
commit 710fa822a0
3 changed files with 43 additions and 20 deletions

View File

@@ -7,7 +7,7 @@ extern crate solana;
use clap::{App, Arg};
use solana::crdt::{NodeInfo, TestNode};
use solana::fullnode::{Config, FullNode, Ledger};
use solana::fullnode::{Config, FullNode, LedgerFile};
use solana::service::Service;
use solana::signature::{KeyPair, KeyPairUtil};
use std::fs::File;
@@ -64,9 +64,9 @@ fn main() -> () {
}
}
let ledger = if let Some(l) = matches.value_of("ledger") {
Ledger::Path(l.to_string())
LedgerFile::Path(l.to_string())
} else {
Ledger::StdInOut
LedgerFile::StdInOut
};
let mut node = TestNode::new_with_bind_addr(repl_data, bind_addr);

View File

@@ -30,7 +30,7 @@ pub struct FullNode {
thread_hdls: Vec<JoinHandle<()>>,
}
pub enum Ledger {
pub enum LedgerFile {
StdInOut,
Path(String),
}
@@ -61,14 +61,14 @@ impl FullNode {
pub fn new(
mut node: TestNode,
leader: bool,
ledger: Ledger,
ledger: LedgerFile,
keypair_for_validator: Option<KeyPair>,
network_entry_for_validator: Option<SocketAddr>,
) -> FullNode {
info!("creating bank...");
let bank = Bank::default();
let (infile, outfile): (Box<Read>, Box<Write + Send>) = match ledger {
Ledger::Path(path) => (
LedgerFile::Path(path) => (
Box::new(File::open(path.clone()).expect("opening ledger file")),
Box::new(
OpenOptions::new()
@@ -78,7 +78,7 @@ impl FullNode {
.expect("opening ledger file"),
),
),
Ledger::StdInOut => (Box::new(stdin()), Box::new(stdout())),
LedgerFile::StdInOut => (Box::new(stdin()), Box::new(stdout())),
};
let reader = BufReader::new(infile);
let entries = entry_writer::read_entries(reader).map(|e| e.expect("failed to parse entry"));