added tracing

This commit is contained in:
Robert Habermeier 2016-06-10 14:15:20 +02:00
parent c6e83caddf
commit f689792481
2 changed files with 12 additions and 2 deletions

View File

@ -760,6 +760,8 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
let best_header_bytes = self.best_block_header();
let best_header = HeaderView::new(&best_header_bytes);
trace!(target: "pv64_snapshot", "Taking snapshot starting at block {}", best_header.number());
let mut manifest_hashes = Vec::new();
// lock the state db while we create the state chunks.
@ -774,7 +776,7 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
let mut path = root_dir.to_owned();
path.push("snapshot/");
::std::fs::create_dir(&path).unwrap();
let _ = ::std::fs::create_dir(&path);
let block_chunk_hashes = BlockChunker::new(self, best_hash, genesis_hash).chunk_all(&path);
for hash in block_chunk_hashes {

View File

@ -60,6 +60,7 @@ impl<'a> BlockChunker<'a> {
// This will return true if it created a block chunk, false otherwise.
fn fill_buffers(&mut self) -> bool {
let mut loaded_size = 0;
let mut blocks_loaded = 0;
while loaded_size < PREFERRED_CHUNK_SIZE && self.current_hash != self.genesis_hash {
@ -80,9 +81,14 @@ impl<'a> BlockChunker<'a> {
self.current_hash = BlockView::new(&block).header_view().parent_hash();
self.rlps.push_front((block, receipts));
blocks_loaded += 1;
}
loaded_size == 0
if blocks_loaded > 0 {
trace!(target: "pv64_snapshot", "prepared block chunk with {} blocks", blocks_loaded);
}
loaded_size != 0
}
// write out the data in the buffers to a chunk on disk
@ -96,6 +102,8 @@ impl<'a> BlockChunker<'a> {
let raw_data = rlp_stream.out();
let hash = raw_data.sha3();
trace!(target: "pv64_snapshot", "writing block chunk. hash: {}, size: {} bytes", hash.hex(), raw_data.len());
let mut file_path = path.to_owned();
file_path.push(hash.hex());