Skip to content

Commit

Permalink
Remove already exists target before ckb-sync start
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Jan 9, 2025
1 parent e40e17a commit a5225d5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions shared/src/shared_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,25 @@ impl SharedBuilder {
let block_status_map = Arc::new(DashMap::new());

let assume_valid_targets = Arc::new(Mutex::new({
if Self::check_assume_valid_target_already_exists(&sync_config, &snapshot) {
let not_exists_targets: Option<Vec<H256>> =
sync_config.assume_valid_targets.map(|targets| {
targets
.iter()
.filter(|&target_hash| {
let exists = snapshot.block_exists(target_hash);
if exists {
info!("assume valid target 0x{} already exists in db", target_hash);
}
exists
})
.collect::<Vec<H256>>()
});

if not_exists_targets.is_some_and(|targets| targets.is_empty()) {
info!("all assume valid targets is already in db, CKB will do full verification from now on");
None
} else {
sync_config.assume_valid_targets.clone()
not_exists_targets
}
}));

Expand Down

0 comments on commit a5225d5

Please sign in to comment.