make the leader append to the ledger file

This commit is contained in:
Rob Walker
2018-07-03 15:05:53 -07:00
committed by Greg Fitzgerald
parent f38842822f
commit 800c2dd370
2 changed files with 10 additions and 7 deletions

View File

@ -6,7 +6,7 @@ use entry_writer;
use ncp::Ncp; use ncp::Ncp;
use packet::BlobRecycler; use packet::BlobRecycler;
use rpu::Rpu; use rpu::Rpu;
use std::fs::File; use std::fs::{File, OpenOptions};
use std::io::{sink, stdin, stdout, BufReader}; use std::io::{sink, stdin, stdout, BufReader};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::net::SocketAddr; use std::net::SocketAddr;
@ -85,9 +85,13 @@ impl FullNode {
} else { } else {
node.data.current_leader_id = node.data.id.clone(); node.data.current_leader_id = node.data.id.clone();
let outfile_for_leader: Box<Write + Send> = match outfile_for_leader { let outfile_for_leader: Box<Write + Send> = match outfile_for_leader {
Some(OutFile::Path(file)) => { Some(OutFile::Path(file)) => Box::new(
Box::new(File::create(file).expect("opening ledger file")) OpenOptions::new()
} .create(true)
.append(true)
.open(file)
.expect("opening ledger file"),
),
Some(OutFile::StdOut) => Box::new(stdout()), Some(OutFile::StdOut) => Box::new(stdout()),
None => Box::new(sink()), None => Box::new(sink()),
}; };

View File

@ -7,7 +7,7 @@ extern crate solana;
use solana::crdt::TestNode; use solana::crdt::TestNode;
use solana::crdt::{Crdt, ReplicatedData}; use solana::crdt::{Crdt, ReplicatedData};
use solana::entry_writer::EntryWriter; use solana::entry_writer::EntryWriter;
use solana::fullnode::{FullNode, InFile}; use solana::fullnode::{FullNode, InFile, OutFile};
use solana::logger; use solana::logger;
use solana::mint::Mint; use solana::mint::Mint;
use solana::ncp::Ncp; use solana::ncp::Ncp;
@ -244,7 +244,6 @@ fn test_multi_node_basic() {
} }
#[test] #[test]
#[ignore]
fn test_boot_validator_from_file() { fn test_boot_validator_from_file() {
logger::setup(); logger::setup();
let leader = TestNode::new(); let leader = TestNode::new();
@ -257,7 +256,7 @@ fn test_boot_validator_from_file() {
true, true,
InFile::Path(ledger_path.clone()), InFile::Path(ledger_path.clone()),
None, None,
None, Some(OutFile::Path(ledger_path.clone())),
exit.clone(), exit.clone(),
); );
let leader_balance = let leader_balance =