removed size tolerance
This commit is contained in:
parent
f689792481
commit
b047eb29a1
@ -19,9 +19,6 @@
|
|||||||
// Try to have chunks be around 16MB
|
// Try to have chunks be around 16MB
|
||||||
const PREFERRED_CHUNK_SIZE: usize = 16 * 1024 * 1024;
|
const PREFERRED_CHUNK_SIZE: usize = 16 * 1024 * 1024;
|
||||||
|
|
||||||
// But tolerate ones within a quarter of a megabyte of that size.
|
|
||||||
const SIZE_TOLERANCE: usize = 250 * 1024;
|
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@ -70,10 +67,9 @@ impl<'a> BlockChunker<'a> {
|
|||||||
|
|
||||||
let new_loaded_size = loaded_size + (block.len() + receipts.len());
|
let new_loaded_size = loaded_size + (block.len() + receipts.len());
|
||||||
|
|
||||||
// todo [rob]: find a better chunking strategy -- this will likely
|
// cut off the chunk if too large
|
||||||
// result in the last chunk created being small.
|
if new_loaded_size > PREFERRED_CHUNK_SIZE {
|
||||||
if new_loaded_size > PREFERRED_CHUNK_SIZE + SIZE_TOLERANCE {
|
break;
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
loaded_size = new_loaded_size;
|
loaded_size = new_loaded_size;
|
||||||
}
|
}
|
||||||
@ -93,7 +89,7 @@ impl<'a> BlockChunker<'a> {
|
|||||||
|
|
||||||
// write out the data in the buffers to a chunk on disk
|
// write out the data in the buffers to a chunk on disk
|
||||||
fn write_chunk(&mut self, path: &Path) -> H256 {
|
fn write_chunk(&mut self, path: &Path) -> H256 {
|
||||||
// Todo: compress raw data, put parent hash and block number into chunk.
|
// Todo [rob]: compress raw data, put parent hash and block number into chunk.
|
||||||
let mut rlp_stream = RlpStream::new_list(self.rlps.len());
|
let mut rlp_stream = RlpStream::new_list(self.rlps.len());
|
||||||
for (block, receipts) in self.rlps.drain(..) {
|
for (block, receipts) in self.rlps.drain(..) {
|
||||||
rlp_stream.begin_list(2).append(&block).append(&receipts);
|
rlp_stream.begin_list(2).append(&block).append(&receipts);
|
||||||
|
Loading…
Reference in New Issue
Block a user