Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add headers limit when reorg #40

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/cli/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
NonZeroU32::MAX,
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)?;
Expand Down