From 0c0edc63c0ab966d7bb934850c80347dd1b8292b Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Thu, 10 Oct 2024 11:15:47 +0800 Subject: [PATCH 1/2] add headers limit when reorg. --- src/cli/serve.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index c7df5b6..5beec91 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -196,7 +196,7 @@ impl Args { let (spv_client, spv_update) = storage.generate_spv_client_and_spv_update( spv_tip_height, - NonZeroU32::MAX, + self.spv_headers_update_limit, input.info.get_flags()?, )?; From 933646d36e8ad5978586d492cc18679e8f344b58 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Fri, 11 Oct 2024 13:05:13 +0800 Subject: [PATCH 2/2] add limit for testnet 3 only. --- src/cli/serve.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 5beec91..f8e5a06 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -9,7 +9,11 @@ use std::{ thread, time, }; -use ckb_bitcoin_spv_verifier::types::{core::SpvClient, packed, prelude::Pack as VPack}; +use ckb_bitcoin_spv_verifier::types::{ + core::{BitcoinChainType, SpvClient}, + packed, + prelude::Pack as VPack, +}; use ckb_jsonrpc_types::{Status, TransactionView}; use ckb_sdk::{ core::TransactionBuilder, @@ -194,11 +198,13 @@ impl Args { let spv_tip_height = input.curr.client.headers_mmr_root.max_height; - let (spv_client, spv_update) = storage.generate_spv_client_and_spv_update( - spv_tip_height, - self.spv_headers_update_limit, - input.info.get_flags()?, - )?; + let flags = input.info.get_flags()?; + let limit = match flags.into() { + BitcoinChainType::Testnet => self.spv_headers_update_limit, + _ => NonZeroU32::MAX, + }; + let (spv_client, spv_update) = + storage.generate_spv_client_and_spv_update(spv_tip_height, limit, flags)?; let tx_hash = self.reorg_spv_cells(&spv_service, input, spv_client, spv_update)?;