Skip to content
Snippets Groups Projects

Resolve "blockchain: move sync apply code in block applicator"

4 files
+ 261
177
Compare changes
  • Side-by-side
  • Inline

Files

@@ -34,24 +34,29 @@ pub fn execute(
@@ -34,24 +34,29 @@ pub fn execute(
let mut chunk_index = 0;
let mut chunk_index = 0;
let mut all_wait_duration = Duration::from_millis(0);
let mut all_wait_duration = Duration::from_millis(0);
let mut wait_begin = SystemTime::now();
let mut wait_begin = SystemTime::now();
while let Ok(SyncJobsMess::BlocksDBsWriteQuery(req)) = recv.recv() {
all_wait_duration += SystemTime::now().duration_since(wait_begin).unwrap();
// Apply db request
if let Ok(SyncJobsMess::ForkWindowSize(fork_window_size)) = recv.recv() {
req.apply(
while let Ok(SyncJobsMess::BlocksDBsWriteQuery(req)) = recv.recv() {
&blocks_dbs.blockchain_db,
all_wait_duration += SystemTime::now().duration_since(wait_begin).unwrap();
&forks_db,
200, // TODO replace by fork_window_size
Some(target_blockstamp),
)
.expect("Fatal error : Fail to apply DBWriteRequest !");
chunk_index += 1;
// Apply db request
if chunk_index == 250 {
req.apply(
chunk_index = 0;
&blocks_dbs.blockchain_db,
apply_pb.inc();
&forks_db,
 
fork_window_size,
 
Some(target_blockstamp),
 
)
 
.expect("Fatal error : Fail to apply DBWriteRequest !");
 
 
chunk_index += 1;
 
if chunk_index == 250 {
 
chunk_index = 0;
 
apply_pb.inc();
 
}
 
wait_begin = SystemTime::now();
}
}
wait_begin = SystemTime::now();
} else {
 
fatal_error!("Dev error: block worker must first receive fork window size")
}
}
// Increment progress bar (last chunk)
// Increment progress bar (last chunk)
Loading