]> Untitled Git - bdk/commit
feat(chain)!: Add `ApplyBlockError` for `prev_blockhash` validation
author志宇 <hello@evanlinjin.me>
Fri, 6 Feb 2026 15:19:50 +0000 (15:19 +0000)
committer志宇 <hello@evanlinjin.me>
Wed, 22 Apr 2026 04:48:19 +0000 (04:48 +0000)
commit3ef6ed866d364d6f8c9136d0b6696f2b90e572be
tree2c15c917b18822d1cd9f5c0ee4cbd8d563898b1f
parentbf6541b43d3d65f20a7c081129197337f09d25b6
feat(chain)!: Add `ApplyBlockError` for `prev_blockhash` validation

Introduce `ApplyBlockError` enum with two variants:
- `MissingGenesis`: genesis block is missing or would be altered
- `PrevBlockhashMismatch`: block's `prev_blockhash` doesn't match expected

This replaces `MissingGenesisError` in several `LocalChain` methods:
- `from_blocks`
- `from_changeset`
- `apply_changeset`

Also adds test cases for `merge_chains` with `prev_blockhash` scenarios:
- Update displaces invalid block below point of agreement
- Update fills gap with matching `prev_blockhash`
- Cascading eviction through multiple blocks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
crates/chain/src/local_chain.rs
crates/chain/tests/test_local_chain.rs
crates/core/src/checkpoint.rs