Improve initial data load logging

This commit is contained in:
Roman Zeyde 2018-05-27 09:30:57 +03:00
parent ecd7511842
commit 75d88fcec1
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 5 additions and 2 deletions

View File

@ -264,7 +264,7 @@ impl Daemon {
.as_u64()
.expect("`blocks` should be number") as usize;
let all_heights: Vec<usize> = (0..max_height).collect();
let chunk_size = 10_000;
let chunk_size = 100_000;
let mut result = HeaderMap::new();
let null_hash = Sha256dHash::default();
@ -272,6 +272,7 @@ impl Daemon {
for heights in all_heights.chunks(chunk_size) {
let headers = self.getblockheaders(&heights)?;
assert!(headers.len() == heights.len());
debug!("downloaded {} headers", headers.len());
for header in headers {
blockhash = header.bitcoin_hash();
result.insert(blockhash, header);
@ -294,7 +295,8 @@ impl Daemon {
let mut blockhash = bestblockhash;
while !header_map.contains_key(&blockhash) {
let header = self.getblockheader(&blockhash)
.chain_err(|| "failed to get missing headers")?;
.chain_err(|| format!("failed to get missing header for {}", blockhash))?;
debug!("downloaded {} block header", blockhash);
header_map.insert(blockhash, header);
blockhash = header.prev_blockhash;
}

View File

@ -207,6 +207,7 @@ fn read_indexed_headers(store: &ReadStore) -> HeaderMap {
let header: BlockHeader = deserialize(&row.value).unwrap();
headers.insert(deserialize(&key.hash).unwrap(), header);
}
debug!("read {} block headers from DB", headers.len());
headers
}