feat(chain): add get and range methods to CheckPoint

These methods allow us to query for checkpoints contained within the
linked list by height and height range. This is useful to determine
checkpoints to fetch for chain sources without having to refer back to
the `LocalChain`.

Currently this is not implemented efficiently, but in the future, we
will change `CheckPoint` to use a skip list structure.
This commit is contained in:
志宇
2024-03-06 13:04:12 +08:00
parent 2bb654077d
commit 9a62d56900
7 changed files with 202 additions and 104 deletions

View File

@@ -360,8 +360,8 @@ fn update_local_chain() -> anyhow::Result<()> {
for height in t.request_heights {
let exp_blockhash = blocks.get(height).expect("block must exist in bitcoind");
assert_eq!(
chain.blocks().get(height),
Some(exp_blockhash),
chain.get(*height).map(|cp| cp.hash()),
Some(*exp_blockhash),
"[{}:{}] block {}:{} must exist in final chain",
i,
t.name,