Skip to content

Commit a5225d5

Browse files
committed
Remove already exists target before ckb-sync start
1 parent e40e17a commit a5225d5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

shared/src/shared_builder.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,25 @@ impl SharedBuilder {
446446
let block_status_map = Arc::new(DashMap::new());
447447

448448
let assume_valid_targets = Arc::new(Mutex::new({
449-
if Self::check_assume_valid_target_already_exists(&sync_config, &snapshot) {
449+
let not_exists_targets: Option<Vec<H256>> =
450+
sync_config.assume_valid_targets.map(|targets| {
451+
targets
452+
.iter()
453+
.filter(|&target_hash| {
454+
let exists = snapshot.block_exists(target_hash);
455+
if exists {
456+
info!("assume valid target 0x{} already exists in db", target_hash);
457+
}
458+
exists
459+
})
460+
.collect::<Vec<H256>>()
461+
});
462+
463+
if not_exists_targets.is_some_and(|targets| targets.is_empty()) {
464+
info!("all assume valid targets is already in db, CKB will do full verification from now on");
450465
None
451466
} else {
452-
sync_config.assume_valid_targets.clone()
467+
not_exists_targets
453468
}
454469
}));
455470

0 commit comments

Comments
 (0)