Skip to content

Commit 24b975b

Browse files
committed
Let ckb-chain select rigth Switch for assume_valid_target array
1 parent 4eb738b commit 24b975b

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

chain/src/verify.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,22 @@ impl ConsumeUnverifiedBlockProcessor {
199199
switch: Option<Switch>,
200200
) -> VerifyResult {
201201
let switch: Switch = switch.unwrap_or_else(|| {
202-
let mut assume_valid_target = self.shared.assume_valid_target();
203-
match *assume_valid_target {
204-
Some(ref target) => {
205-
// if the target has been reached, delete it
206-
if target
207-
== &ckb_types::prelude::Unpack::<H256>::unpack(&BlockView::hash(block))
208-
{
209-
assume_valid_target.take();
202+
let mut assume_valid_targets = self.shared.assume_valid_targets();
203+
match *assume_valid_targets {
204+
Some(ref mut targets) => {
205+
//
206+
let block_hash: H256 =
207+
ckb_types::prelude::Unpack::<H256>::unpack(&BlockView::hash(block));
208+
if targets.first().eq(&Some(&block_hash)) {
209+
targets.remove(0);
210+
info!("CKB reached one assume_valid_target: 0x{}", block_hash);
211+
}
212+
213+
if targets.is_empty() {
214+
assume_valid_targets.take();
215+
info!(
216+
"CKB reached all assume_valid_targets, will do full verification now"
217+
);
210218
Switch::NONE
211219
} else {
212220
Switch::DISABLE_SCRIPT

0 commit comments

Comments
 (0)