Context API
ContextOptions
Bases: KernelOpaquePtr
Options for creating a new kernel context.
Once a kernel context has been created from this options object, it may be destroyed. Changes made to the options after the kernel context has been created will not be reflected on the kernel context.
Source code in pbk/context.py
__init__
set_chainparams
Sets the chain parameters for the context options.
| PARAMETER | DESCRIPTION |
|---|---|
chain_parameters
|
Chain parameters to set.
TYPE:
|
set_notifications
Sets the kernel notifications for the context options.
| PARAMETER | DESCRIPTION |
|---|---|
notifications
|
Notification callbacks to set.
TYPE:
|
Source code in pbk/context.py
set_validation_interface
Sets the validation interface callbacks for the context options.
| PARAMETER | DESCRIPTION |
|---|---|
interface_callbacks
|
Validation callbacks to set. |
Source code in pbk/context.py
Context
Bases: KernelOpaquePtr
The kernel context is used to initialize internal state and hold the chain parameters and callbacks for handling error and validation events.
Source code in pbk/context.py
__copy__
Return an independent handle to the same kernel context.
Propagates Python-side keepalives for the notification and validation callbacks: the kernel stores raw function pointers into ctypes trampolines owned by these Python objects, so the copy must keep them alive even if the source handle is dropped.
Source code in pbk/context.py
__init__
Create a kernel context.
| PARAMETER | DESCRIPTION |
|---|---|
options
|
Context options to use.
TYPE:
|
Source code in pbk/context.py
__repr__
interrupt
Interrupt long-running validation functions. Useful for operations like reindexing, importing or processing blocks.
| RETURNS | DESCRIPTION |
|---|---|
int
|
0 if interrupt was successful, non-zero otherwise |
Source code in pbk/context.py
make_context
make_context(chain_type: ChainType = ChainType.REGTEST, validation_callbacks: ValidationInterfaceCallbacks | None = None) -> Context
Build a Context for the given chain type.
| PARAMETER | DESCRIPTION |
|---|---|
chain_type
|
The chain parameters to use. |
validation_callbacks
|
Optional callbacks to receive validation events
(block connected, disconnected, etc.). See
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Context
|
A new |