From 95bdcaa71be7df4f370d5d58c635e332567d6ae1 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Fri, 2 Nov 2018 18:49:26 -0700 Subject: [PATCH] use default buffer size for index, use BLOB_DATA_SIZE for data buffer --- src/ledger.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ledger.rs b/src/ledger.rs index 494e7363836842..79774c5912f385 100644 --- a/src/ledger.rs +++ b/src/ledger.rs @@ -77,10 +77,6 @@ pub struct LedgerWindow { pub const LEDGER_DATA_FILE: &str = "data"; const LEDGER_INDEX_FILE: &str = "index"; -const LEDGER_BUF_COUNT: usize = 32 * 1024; -const LEDGER_DATA_BUF_SIZE: usize = LEDGER_BUF_COUNT * BLOB_DATA_SIZE; -const LEDGER_INDEX_BUF_SIZE: usize = LEDGER_BUF_COUNT * SIZEOF_U64 as usize; - // use a CONST because there's a cast, and we don't want "sizeof:: as u64"... const SIZEOF_U64: u64 = size_of::() as u64; @@ -116,9 +112,9 @@ impl LedgerWindow { let ledger_path = Path::new(&ledger_path); let index = File::open(ledger_path.join(LEDGER_INDEX_FILE))?; - let index = BufReader::with_capacity(LEDGER_INDEX_BUF_SIZE, index); + let index = BufReader::new(index); let data = File::open(ledger_path.join(LEDGER_DATA_FILE))?; - let data = BufReader::with_capacity(LEDGER_DATA_BUF_SIZE, data); + let data = BufReader::with_capacity(BLOB_DATA_SIZE, data); Ok(LedgerWindow { index, data }) } @@ -188,10 +184,10 @@ pub fn verify_ledger(ledger_path: &str) -> io::Result<()> { format!("index is not a multiple of {} bytes long", SIZEOF_U64), ))?; } - let mut index = BufReader::with_capacity(LEDGER_INDEX_BUF_SIZE, index); + let mut index = BufReader::new(index); let data = File::open(ledger_path.join(LEDGER_DATA_FILE))?; - let mut data = BufReader::with_capacity(LEDGER_DATA_BUF_SIZE, data); + let mut data = BufReader::with_capacity(BLOB_DATA_SIZE, data); let mut last_data_offset = 0; let mut index_offset = 0;