Skip to content

Commit

Permalink
fix: failed to reorg when only one stale block
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape committed Apr 5, 2024
1 parent ba3f652 commit 46a4814
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/spv_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,20 @@ impl SpvService {
let packed_spv_header_root = spv_header_root.pack();

if packed_stg_header_root.as_slice() == packed_spv_header_root.as_slice() {
let input = SpvReorgInput {
info,
curr: cell.clone(),
stale,
};
return Ok(input);
if stale.len() > 1 {
let input = SpvReorgInput {
info,
curr: cell.clone(),
stale,
};
return Ok(input);
} else {
log::warn!(
"[TODO::KnownIssue] this is a dirty patch to fix an issue in the contract: \
update and reorg only 1 block are indistinguishable, \
let's just reorg 1 more client"
);
}
}

log::trace!("[onchain] header#{spv_height}; mmr-root {spv_header_root}");
Expand Down

0 comments on commit 46a4814

Please sign in to comment.