Validation
ValidationMode
Bases: IntEnum
Result of validation processing.
Indicates whether a data structure (such as a block) passed validation, failed validation, or encountered an error during processing.
Source code in pbk/block.py
BlockValidationResult
Bases: IntEnum
Specific reason why a block failed validation.
Provides detailed information about which validation rule was violated when a block is rejected. These results help diagnose why blocks fail to be accepted into the blockchain.
Source code in pbk/block.py
BlockValidationState
Bases: KernelOpaquePtr
State of a block during validation.
Contains information about whether validation was successful and, if not, which specific validation step failed. This state is provided to validation interface callbacks to communicate detailed validation results.
Source code in pbk/block.py
block_validation_result
property
Specific validation failure reason.
| RETURNS | DESCRIPTION |
|---|---|
BlockValidationResult
|
The granular reason why validation failed, or UNSET if valid. |
validation_mode
property
Overall validation result.
| RETURNS | DESCRIPTION |
|---|---|
ValidationMode
|
Whether the block is valid, invalid, or encountered an error. |
ValidationInterfaceCallbacks
Bases: btck_ValidationInterfaceCallbacks
Callbacks for receiving validation events.
These callbacks allow monitoring of block validation progress and results. Callbacks are invoked synchronously during validation and will block further validation execution until they complete, so they should execute quickly.
All callbacks are optional; only those passed as keyword arguments are registered, and any unspecified event is silently ignored.
Available callbacks, each invoked with (block, entry_or_state):
- block_checked(block: Block, state: BlockValidationState):
a block has been fully validated. state is only valid for the duration
of the callback — do not retain it.
- pow_valid_block(block: Block, entry: BlockTreeEntry):
a block extends the header chain with valid PoW.
- block_connected(block: Block, entry: BlockTreeEntry):
a valid block was connected to the best chain.
- block_disconnected(block: Block, entry: BlockTreeEntry):
a block was disconnected during a reorg.
block is owned by the callback; entry is a view into the kernel's
block index and remains valid for the kernel's lifetime.
Example
Register only block_disconnected:
cbs = ValidationInterfaceCallbacks( ... block_disconnected=lambda block, entry: print(entry.height) ... )
Source code in pbk/validation.py
__init__
Create validation interface callbacks.
| PARAMETER | DESCRIPTION |
|---|---|
**callbacks
|
Callback functions for validation events, keyed by callback name
(e.g.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If an unknown callback name is passed. |