Skip to content

Commit 7294c09

Browse files
committed
Merge remote-tracking branch 'alex/must-use'
2 parents 1dbab61 + 52d6462 commit 7294c09

3 files changed

Lines changed: 3 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- 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.
1212
- Implemented `Debug` for `BlockValidationResult`, `BlockValidationStateRef`, `ProcessBlockHeaderresult` and `BlockCheckResult`, enabling inspection via `{:?}` in logs and test output.
13+
- Added `#[must_use]` to `BlockCheckResult` and `ProcessBlockHeaderResult` to warn when validation results are silently ignored.
1314

1415
### Changed
1516
- The `verify` function's `flags` parameter now uses `ScriptVerificationFlags` instead of `u32`, making the type explicit in the public API.

src/core/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pub const BLOCK_CHECK_ALL: BlockCheckFlags = btck_BlockCheckFlags_ALL;
177177
/// On failure, the [`BlockValidationState`] carries details that can be
178178
/// inspected via [`BlockValidationStateExt`](crate::notifications::BlockValidationStateExt).
179179
#[derive(Clone, Debug)]
180+
#[must_use = "check result must be inspected to determine whether the block is valid"]
180181
pub enum BlockCheckResult {
181182
/// The block passed the requested context-free checks.
182183
Valid,

src/state/chainstate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub enum ProcessBlockResult {
7474
///
7575
/// Indicates whether a block header was processed, or rejected, and whether it is valid.
7676
#[derive(Clone, Debug)]
77+
#[must_use = "header processing result must be inspected to determine whether processing completed successfully"]
7778
pub enum ProcessBlockHeaderResult {
7879
/// Header was succssfully processed and added to the block tree
7980
Success(BlockValidationState),

0 commit comments

Comments
 (0)