]> Untitled Git - bdk/commitdiff
feat(core): derive `Debug` for `BlockQueries` pre-fold-backup
author志宇 <hello@evanlinjin.me>
Thu, 10 Sep 2026 11:03:38 +0000 (11:03 +0000)
committer志宇 <hello@evanlinjin.me>
Fri, 11 Sep 2026 02:00:25 +0000 (02:00 +0000)
`BlockQueries` is half of `CanonicalTask::Output`, so without `Debug` the
task's own output tuple isn't `Debug` — `dbg!(chain.run_task(task))` and
`.unwrap()` on a `Result` in that position don't compile. Its neighbours
`BlockCandidateResolution` and `Canonical` already derive it (Rust API
guideline C-DEBUG).

Covered by formatting the output tuple in the existing `CanonicalTask`
test, so the derive can't be dropped without a test failing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NND8BhEmYTYdLRv4dbUUro

crates/chain/src/canonical_task.rs
crates/core/src/block_queries.rs

index 46b99c3de1391fa785c335af98375f0ab2d84d70..283188c5488c6fc1c3259439adc32fb35ef1f3fe 100644 (file)
@@ -512,7 +512,11 @@ mod tests {
         // Create canonicalization task and canonicalize using the two-step pipeline
         let params = CanonicalParams::default();
         let task = CanonicalTask::new(&tx_graph, chain_tip, params);
-        let (txs, queries) = chain.run_task(task);
+        let output = chain.run_task(task);
+        // `CanonicalTask::Output` is `(CanonicalTxs, BlockQueries)`. Both halves must be
+        // `Debug` or callers cannot `dbg!()` it, or `.unwrap()` it out of a `Result`.
+        let _ = alloc::format!("{output:?}");
+        let (txs, queries) = output;
         let view_task = txs.view_task(&tx_graph, queries);
         let canonical_view = chain.run_task(view_task);
 
index 48d1a69423e56ad5f012b2fa4a90cb163e538ff3..533f8b78da0aaea2e8d2b2b2d31e8430ced3ea3e 100644 (file)
@@ -17,6 +17,7 @@ use alloc::vec::Vec;
 /// 2. Feed responses back via [`resolve`](Self::resolve).
 /// 3. Look up resolved blocks with [`get`](Self::get).
 /// 4. Check for outstanding requests with [`unresolved`](Self::unresolved).
+#[derive(Debug)]
 pub struct BlockQueries<B> {
     pending: BTreeSet<u32>,
     blocks: BTreeMap<u32, Option<B>>,