Banish stdin/stdout for ledger
step one: accept a "ledger file" argument instead of "outfile"
This commit is contained in:
@@ -9,7 +9,7 @@ extern crate solana;
|
||||
use atty::{is, Stream};
|
||||
use clap::{App, Arg};
|
||||
use solana::crdt::{NodeInfo, TestNode};
|
||||
use solana::fullnode::{Config, FullNode, InFile, OutFile};
|
||||
use solana::fullnode::{Config, FullNode, Ledger};
|
||||
use solana::service::Service;
|
||||
use solana::signature::{KeyPair, KeyPairUtil};
|
||||
use std::fs::File;
|
||||
@@ -37,12 +37,12 @@ fn main() -> () {
|
||||
.help("testnet; connect to the network at this gossip entry point"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("output")
|
||||
.short("o")
|
||||
.long("output")
|
||||
Arg::with_name("ledger")
|
||||
.short("L")
|
||||
.long("ledger")
|
||||
.value_name("FILE")
|
||||
.takes_value(true)
|
||||
.help("output log to FILE, defaults to stdout (ignored by validators)"),
|
||||
.help("use FILE as persistent ledger (defaults to stdin/stdout)"),
|
||||
)
|
||||
.get_matches();
|
||||
if is(Stream::Stdin) {
|
||||
@@ -69,27 +69,22 @@ fn main() -> () {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
let ledger = if let Some(l) = matches.value_of("ledger") {
|
||||
Ledger::Path(l.to_string())
|
||||
} else {
|
||||
Ledger::StdInOut
|
||||
};
|
||||
|
||||
let mut node = TestNode::new_with_bind_addr(repl_data, bind_addr);
|
||||
let fullnode = if let Some(t) = matches.value_of("testnet") {
|
||||
let testnet_address_string = t.to_string();
|
||||
let testnet_addr = testnet_address_string.parse().unwrap();
|
||||
FullNode::new(
|
||||
node,
|
||||
false,
|
||||
InFile::StdIn,
|
||||
Some(keypair),
|
||||
Some(testnet_addr),
|
||||
None,
|
||||
)
|
||||
|
||||
FullNode::new(node, false, ledger, Some(keypair), Some(testnet_addr))
|
||||
} else {
|
||||
node.data.leader_id = node.data.id;
|
||||
|
||||
let outfile = if let Some(o) = matches.value_of("output") {
|
||||
OutFile::Path(o.to_string())
|
||||
} else {
|
||||
OutFile::StdOut
|
||||
};
|
||||
FullNode::new(node, true, InFile::StdIn, None, None, Some(outfile))
|
||||
FullNode::new(node, true, ledger, None, None)
|
||||
};
|
||||
fullnode.join().expect("join");
|
||||
}
|
||||
|
Reference in New Issue
Block a user