Skip to content

Extensions

Extension

Base class of all extensions

init(substrate: SubstrateInterface)

Initialization process of the extension. This function is being called by the ExtensionRegistry.

Parameters:

Name Type Description Default
substrate SubstrateInterface required

close()

Cleanup process of the extension. This function is being called by the ExtensionRegistry.

debug_message(message: str)

Submits a debug message in the logger

Parameters:

Name Type Description Default
message str required

SearchExtension

Bases: Extension

Type of Extension that implements functionality to improve and enhance search capability

filter_events(**kwargs) -> list

Filters events to match provided search criteria e.g. block range, pallet name, accountID in attributes

Parameters:

Name Type Description Default
kwargs {}

Returns:

Type Description
list

filter_extrinsics(**kwargs) -> list

Filters extrinsics to match provided search criteria e.g. block range, pallet name, signed by accountID

Parameters:

Name Type Description Default
kwargs {}

search_block_number(block_datetime: datetime, block_time: int = 6, **kwargs) -> int

Search corresponding block number for provided block_datetime. the prediction tolerance is provided with block_time

Parameters:

Name Type Description Default
block_datetime datetime required
block_time int 6
kwargs {}

Returns:

Type Description
int

get_block_timestamp(block_number: int) -> int

Return a UNIX timestamp for given block_number.

Parameters:

Name Type Description Default
block_number int required

Returns:

Type Description
int

SubstrateNodeExtension

Bases: SearchExtension

Implementation of SearchExtension using only Substrate RPC methods. Could be significant inefficient.

search_block_number(block_datetime: datetime, block_time: int = 6, **kwargs) -> int

Search corresponding block number for provided block_datetime. the prediction tolerance is provided with block_time

Parameters:

Name Type Description Default
block_datetime datetime required
block_time int 6
kwargs {}

Returns:

Type Description
int