Added check in write stage to exit when scheduled entry_height for leader rotation is detected

This commit is contained in:
Carl
2018-09-11 18:40:38 -07:00
committed by Greg Fitzgerald
parent 91cf14e641
commit f28ba3937b
5 changed files with 320 additions and 16 deletions

View File

@@ -7,10 +7,14 @@ use entry::Entry;
use hash::Hash;
use instruction::Vote;
use log::Level::Trace;
#[cfg(test)]
use mint::Mint;
use packet::{self, SharedBlob, BLOB_DATA_SIZE};
use rayon::prelude::*;
use result::{Error, Result};
use signature::Pubkey;
#[cfg(test)]
use signature::{Keypair, KeypairUtil};
use std::fs::{create_dir_all, remove_dir_all, File, OpenOptions};
use std::io::prelude::*;
use std::io::{self, BufReader, BufWriter, Seek, SeekFrom};
@@ -542,6 +546,20 @@ pub fn next_entries(
next_entries_mut(&mut id, &mut num_hashes, transactions)
}
#[cfg(test)]
pub fn tmp_ledger_path(name: &str) -> String {
let keypair = Keypair::new();
format!("/tmp/tmp-ledger-{}-{}", name, keypair.pubkey())
}
#[cfg(test)]
pub fn genesis(name: &str, num: i64) -> (Mint, String) {
let mint = Mint::new(num);
let path = tmp_ledger_path(name);
let mut writer = LedgerWriter::open(&path, true).unwrap();
writer.write_entries(mint.create_entries()).unwrap();
(mint, path)
}
#[cfg(test)]
mod tests {
use super::*;