-
Couldn't load subscription status.
- Fork 412
Open
Milestone
Description
Problem
Need to efficiently determine if two CheckPoint chains contain the same set of blocks. Currently requires O(n) traversal to compare sparse chains, even when they have the same tip.
Solution
Add a cumulative XOR field to each CheckPoint that represents the XOR of all block hashes in the sparse chain.
Why XOR Works
- Bitcoin blocks have unique hashes (no collisions)
- XOR is commutative: same blocks = same XOR regardless of order
- O(1) comparison instead of O(n) traversal
- Simple incremental computation during
insert()
Testing Requirements
- XOR correctly computed during construction
- XOR maintained during
insert()operations - Same sparse chains produce identical XOR
- Different sparse chains produce different XOR
- Edge cases: empty chain, single block, fork handling
Notes
- 32 bytes per checkpoint overhead (acceptable for O(1) comparison benefit)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Discussion