Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,16 @@ impl Daemon {
let chunk_size = 100_000;
let mut result = vec![];
for heights in all_heights.chunks(chunk_size) {
trace!("downloading {} block headers", heights.len());
let mut headers = self.getblockheaders(&heights)?;
assert!(headers.len() == heights.len());

result.append(&mut headers);

info!("downloaded {}/{} block headers ({:.0}%)",
result.len(),
tip_height,
result.len() as f32 / tip_height as f32 * 100.0);

}

let mut blockhash = *DEFAULT_BLOCKHASH;
Expand All @@ -792,7 +798,7 @@ impl Daemon {
) -> Result<Vec<BlockHeader>> {
// Iterate back over headers until known blockash is found:
if indexed_headers.is_empty() {
debug!("downloading all block headers up to {}", bestblockhash);
info!("downloading all block headers up to {}", bestblockhash);
return self.get_all_headers(bestblockhash);
}
debug!(
Expand Down
4 changes: 2 additions & 2 deletions src/new_index/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl DB {

pub fn full_compaction(&self) {
// TODO: make sure this doesn't fail silently
debug!("starting full compaction on {:?}", self.db);
info!("starting full compaction on {:?}", self.db);
self.db.compact_range(None::<&[u8]>, None::<&[u8]>);
debug!("finished full compaction on {:?}", self.db);
info!("finished full compaction on {:?}", self.db);
}

pub fn enable_auto_compaction(&self) {
Expand Down
30 changes: 29 additions & 1 deletion src/new_index/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,20 @@ fn bitcoind_fetcher(
Ok(Fetcher::from(
chan.into_receiver(),
spawn_thread("bitcoind_fetcher", move || {
let mut fetcher_count = 0;
let mut blocks_fetched = 0;
let total_blocks_fetched = new_headers.len();
for entries in new_headers.chunks(100) {
if fetcher_count % 50 == 0 && total_blocks_fetched >= 50 {
info!("fetching blocks {}/{} ({:.1}%)",
blocks_fetched,
total_blocks_fetched,
blocks_fetched as f32 / total_blocks_fetched as f32 * 100.0
);
}
fetcher_count += 1;
blocks_fetched += entries.len();

let blockhashes: Vec<BlockHash> = entries.iter().map(|e| *e.hash()).collect();
let blocks = daemon
.getblocks(&blockhashes)
Expand Down Expand Up @@ -129,9 +142,17 @@ fn blkfiles_fetcher(
chan.into_receiver(),
spawn_thread("blkfiles_fetcher", move || {
parser.map(|sizedblocks| {
let block_count = sizedblocks.len();
let mut index = 0;
let block_entries: Vec<BlockEntry> = sizedblocks
.into_iter()
.filter_map(|(block, size)| {
index += 1;
debug!("fetch block {:}/{:} {:.2}%",
index,
block_count,
(index/block_count) as f32/100.0
);
let blockhash = block.block_hash();
entry_map
.remove(&blockhash)
Expand Down Expand Up @@ -165,7 +186,14 @@ fn blkfiles_reader(blk_files: Vec<PathBuf>, xor_key: Option<[u8; 8]>) -> Fetcher
Fetcher::from(
chan.into_receiver(),
spawn_thread("blkfiles_reader", move || {
for path in blk_files {
let blk_files_len = blk_files.len();
for (count, path) in blk_files.iter().enumerate() {
info!("block file reading {:}/{:} {:.2}%",
count,
blk_files_len,
count / blk_files_len
);

trace!("reading {:?}", path);
let mut blob = fs::read(&path)
.unwrap_or_else(|e| panic!("failed to read {:?}: {:?}", path, e));
Expand Down
21 changes: 20 additions & 1 deletion src/new_index/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,26 @@ impl Indexer {
to_add.len(),
self.from
);
start_fetcher(self.from, &daemon, to_add)?.map(|blocks| self.add(&blocks));

let mut fetcher_count = 0;
let mut blocks_fetched = 0;
let to_add_total = to_add.len();

start_fetcher(self.from, &daemon, to_add)?.map(|blocks|
{
if fetcher_count % 25 == 0 && to_add_total > 20 {
info!("adding txes from blocks {}/{} ({:.1}%)",
blocks_fetched,
to_add_total,
blocks_fetched as f32 / to_add_total as f32 * 100.0
);
}
fetcher_count += 1;
blocks_fetched += blocks.len();

self.add(&blocks)
});

self.start_auto_compactions(&self.store.txstore_db);

let to_index = self.headers_to_index(&new_headers);
Expand Down