Skip to content

Commit 1e764c9

Browse files
feat(notifications): expose BlockValidationState types in public API
Export BlockValidationStateRef at the crate root and add BlockValidationStateExt to the prelude module. These types allow users to interact with block validation state in validation callbacks. Update internal imports throughout the codebase to use the new public path.
1 parent bb1f22e commit 1e764c9

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

fuzz/fuzz_targets/chainman_process_block.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ use libfuzzer_sys::fuzz_target;
77
use arbitrary::Arbitrary;
88

99
use bitcoinkernel::{
10-
disable_logging,
11-
notifications::types::{BlockValidationStateExt, BlockValidationStateRef},
12-
Block, ChainType, ChainstateManagerBuilder, Context, ContextBuilder, KernelError,
13-
ValidationMode,
10+
disable_logging, prelude::*, Block, BlockValidationStateRef, ChainType,
11+
ChainstateManagerBuilder, Context, ContextBuilder, KernelError, ValidationMode,
1412
};
1513

1614
fn create_context(chain_type: ChainType) -> Arc<Context> {

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ pub use crate::core::{
119119
pub use crate::log::{disable_logging, Log, LogCategory, LogLevel, Logger};
120120

121121
pub use crate::notifications::{
122-
BlockCheckedCallback, BlockTipCallback, BlockValidationResult, FatalErrorCallback,
123-
FlushErrorCallback, HeaderTipCallback, NotificationCallbackRegistry, ProgressCallback,
124-
SynchronizationState, ValidationCallbackRegistry, ValidationMode, Warning, WarningSetCallback,
125-
WarningUnsetCallback,
122+
BlockCheckedCallback, BlockTipCallback, BlockValidationResult, BlockValidationStateRef,
123+
FatalErrorCallback, FlushErrorCallback, HeaderTipCallback, NotificationCallbackRegistry,
124+
ProgressCallback, SynchronizationState, ValidationCallbackRegistry, ValidationMode, Warning,
125+
WarningSetCallback, WarningUnsetCallback,
126126
};
127127

128128
pub use crate::state::{
@@ -140,4 +140,5 @@ pub mod prelude {
140140
BlockHashExt, BlockSpentOutputsExt, CoinExt, ScriptPubkeyExt, TransactionExt,
141141
TransactionSpentOutputsExt, TxOutExt,
142142
};
143+
pub use crate::notifications::BlockValidationStateExt;
143144
}

src/notifications/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ pub mod notification;
22
pub mod types;
33
pub mod validation;
44

5-
pub use types::{BlockValidationResult, SynchronizationState, ValidationMode, Warning};
5+
pub use types::{
6+
BlockValidationResult, BlockValidationStateExt, BlockValidationStateRef, SynchronizationState,
7+
ValidationMode, Warning,
8+
};
69

710
pub use notification::{
811
BlockTipCallback, FatalErrorCallback, FlushErrorCallback, HeaderTipCallback,

src/notifications/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ impl<'a> BlockValidationStateExt for BlockValidationStateRef<'a> {}
228228
mod tests {
229229
use libbitcoinkernel_sys::btck_BlockValidationState;
230230

231-
use crate::{
232-
ffi::test_utils::test_ref_trait_requirements, notifications::types::BlockValidationStateRef,
233-
};
231+
use crate::ffi::test_utils::test_ref_trait_requirements;
234232

235233
use super::*;
236234

src/notifications/validation.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use libbitcoinkernel_sys::{btck_Block, btck_BlockTreeEntry, btck_BlockValidation
44

55
use crate::{
66
ffi::sealed::{FromMutPtr, FromPtr},
7-
notifications::types::BlockValidationStateRef,
8-
Block, BlockTreeEntry,
7+
Block, BlockTreeEntry, BlockValidationStateRef,
98
};
109

1110
/// Exposes the result after validating a block.
@@ -184,7 +183,7 @@ pub(crate) unsafe extern "C" fn validation_block_disconnected_wrapper(
184183
mod tests {
185184
use std::sync::{Arc, Mutex};
186185

187-
use crate::{notifications::types::BlockValidationStateExt, BlockValidationResult};
186+
use crate::{prelude::*, BlockValidationResult};
188187

189188
use super::*;
190189

src/state/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl From<btck_ChainType> for ChainType {
368368

369369
#[cfg(test)]
370370
mod tests {
371-
use crate::{notifications::types::BlockValidationStateRef, BlockTreeEntry};
371+
use crate::{BlockTreeEntry, BlockValidationStateRef};
372372

373373
use super::*;
374374

0 commit comments

Comments
 (0)