From 52d646204ee7dd7c1594850774f3cc8634744517 Mon Sep 17 00:00:00 2001 From: Alexander Wiederin Date: Tue, 26 May 2026 18:39:37 +0200 Subject: [PATCH] feat: add #[must_use] to BlockCheckResult and ProcessBlockHeaderResult --- CHANGELOG.md | 1 + src/core/block.rs | 1 + src/state/chainstate.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7e11228..fb4110a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `Block::check` to perform context-free validation of a block (size, weight, coinbase, transactions, sigops), with optional proof-of-work and merkle-root checks toggled via the `BLOCK_CHECK_BASE` / `_POW` / `_MERKLE` / `_ALL` flags. Returns a `BlockCheckResult` enum carrying the validation state on failure. +- Added `#[must_use]` to `BlockCheckResult` and `ProcessBlockHeaderResult` to warn when validation results are silently ignored. ### Changed - The `verify` function's `flags` parameter now uses `ScriptVerificationFlags` instead of `u32`, making the type explicit in the public API. diff --git a/src/core/block.rs b/src/core/block.rs index 5b2de2e0..3f3180fd 100644 --- a/src/core/block.rs +++ b/src/core/block.rs @@ -176,6 +176,7 @@ pub const BLOCK_CHECK_ALL: BlockCheckFlags = btck_BlockCheckFlags_ALL; /// /// On failure, the [`BlockValidationState`] carries details that can be /// inspected via [`BlockValidationStateExt`](crate::notifications::BlockValidationStateExt). +#[must_use = "check result must be inspected to determine whether the block is valid"] pub enum BlockCheckResult { /// The block passed the requested context-free checks. Valid, diff --git a/src/state/chainstate.rs b/src/state/chainstate.rs index afaf2dca..e4ad3605 100644 --- a/src/state/chainstate.rs +++ b/src/state/chainstate.rs @@ -73,6 +73,7 @@ pub enum ProcessBlockResult { /// Result of proceesing a header with the [`ChainstateManager`] /// /// Indicates whether a block header was processed, or rejected, and whether it is valid. +#[must_use = "header processing result must be inspected to determine whether processing completed successfully"] #[derive(Clone)] pub enum ProcessBlockHeaderResult { /// Header was succssfully processed and added to the block tree