BEP 52 (2/16): Merkle tree module#568
Conversation
|
Can we restructure the approach, so that there's no unused code? |
|
I'll rework the plan to completely avoid dead code and try to vertically slice as much as possible incrementally adding functionality and minimizing risk to existing code. |
|
Update for PR2 after review feedback (commit
Validation run after these changes:
All passed. |
|
As I said already, let's do other parts first, I want to see this used first before I spend time reviewing it again. It's all dead code, so let's do it only when it's actually needed (and I guess we won't need all of it, at least on the first use) |
Summary
Implements PR 2 from
docs/BEP52-INCREMENTAL-PR-PLAN.md(Merkle Tree Module).crates/librqbit_core/src/merkle.rswith BEP 52 merkle primitives:MERKLE_BLOCK_SIZEMerkleErrorzero_hash(),hash_block(),hash_pair()compute_merkle_root()returningMerkleResult { root, piece_hashes }verify_piece(),verify_block_with_proof()padding_piece_hash(),root_from_piece_layer()crates/librqbit_core/src/lib.rs(feature-gated with sha1 backends).verify_piece()verify_block_with_proof()padded leaf count <= 8) while keeping Vec path for larger trees.BEP 52 Roadmap
This is PR 2 of 16 implementing BEP 52 (BitTorrent v2) support.
See https://gist.github.com/meatsquirk/533cae01ad9ba49834ffbb3bb3edc469 for the full stacked plan.
Test plan
cargo +1.90.0 check --all-targetscargo +1.90.0 clippy --all-targets -- -D warnings -D dead_code -D unused_variablescargo +1.90.0 test -p librqbit-core merkle🤖 Generated with Claude Code
Latest Update (2026-02-15)
Follow-up commit
217e3488applies review-driven improvements tomerkle.rs:compute_merkle_root_streaming().verify_piece) with no double chunk iteration.padding_piece_hash().ct_eq_id32) in verification paths.Additional validation run after this update:
cargo checkcargo clippy --all-targetscargo test -p librqbit-core merkle::tests::cargo test --workspaceAll passed.