Options
All
  • Public
  • Public/Protected
  • All
Menu
description

The implementation for the block discovery scheduler. Contains source code for the execution logic of a command with name: discovery:DiscoverBlocks.

since

v0.3.2

Hierarchy

Index

Constructors

Properties

argv: string[] = []

The arguments passed to the command. Typically, this holds required parameters of commands.

access

protected

var

{string[]}

blocks: BlockInfo[] = []

Memory store for all blocks processed in one run of this command.

access

protected

var

{SdkTransaction[]}

blocksService: BlocksService
configService: ConfigService<Record<string, unknown>, false>
dappConfig: DappConfig

The internal dApp configuration object. This object is used to configure key functionalities such as the name of a dApp and the enabled scopes of the backend runtime.

access

protected

var

{DappConfig}

dappHelper: DappHelper
discoverySource: Address

The discovery source. In most cases this will be the host dapp's main account public key.

access

protected

var

{Address}

lastExecutedAt: number

Memory store for the last time of execution. This is used in getStateData to update the latest execution state.

access

private

var

{number}

lastPageNumber: number

Memory store for the last page number being read. This is used in getStateData to update the latest execution state.

access

private

var

{number}

lastRange: number

Memory store for the last processed range of blocks. This is used in getStateData to update the latest execution state.

access

private

var

{number}

logService: LogService
logger: LogService
model: BlockModel
networkConfig: NetworkConfig

The internal dApp network configuration object. This object is used to configure the access to the underlying blockchain network.

access

protected

var

{NetworkConfig}

networkService: NetworkService
scope: string = "discovery"

The command scope. This is the scope that must be enabled through the configuration files for this command to be available.

This property is required through the extension of BaseCommand.

access

protected

var

{Scope}

Requires state information of the module. This object is typically populated upon first execution and updated any time later.

see

StateService

access

protected

var

{StateDocument}

stateService: StateService
totalNumberOfBlocks: number

Memory store for the total number of blocks. This is used in getStateData to update the latest execution state.

access

private

var

{number}

transactionsService: TransactionsService
usePageSize: number = 100

Configuration field for the page size to be read. This is used to determine how many blocks are queried per page from the database.

access

private

var

{number}

Accessors

  • get command(): string
  • get signature(): string
  • This method must return a command signature that contains hints on the command name and its required and optional arguments.

    e.g. "command [--option value]"

    This property is required through the extension of DiscoveryCommand.

    see

    DiscoveryCommand

    see

    BaseCommand

    access

    protected

    Returns string

  • get stateIdentifier(): string
  • Getter for the discovery state identifier, e.g. "discovery.accounts", "discovery.transactions", "payout.outputs" etc.

    This method is an implementation necessary because of the extensions of StatefulModule.

    see

    StatefulModule

    access

    public

    var

    {string}

    Returns string

Methods

  • createRanges(blockHeights: number[]): number[]
  • Method to calculate and return the ranges (each range has a size of 100) of the block heights that need to be queried. Each range is a number indicating the last block height of the range.

    e.g. range has value 100 means the range will be 0-100.

    access

    private

    Parameters

    • blockHeights: number[]

      The list of block heights to calculate ranges from.

    Returns number[]

  • debugLog(message: string): void
  • errorLog(message: string, stack?: string): void
  • getNextSource(sources: string[]): Promise<string>
  • This method will find the next relevant discovery source by iterating through the passed sources and checking individual synchronization state.

    Accounts that are fully synchronized require less requests for recent transactions. Note that a per-source state is persisted as well, to keep track of the last page number as well as to keep track of when the runtime reads the latest available page of transactions for said discovery source.

    Parameters

    • sources: string[]

      The discovery sources public keys and/or addresses.

    Returns Promise<string>

    The discovery source address.

  • infoLog(message: string): void
  • parseSource(sourceOption: string): Address
  • This method is the entry point of any command line executed command. nest-commander implements a flow where this method is called with parameters that are respectively the raw arguments and the parsed arguments to this command call.

    This method uses the stateService to fetch the current execution and also uses it to update the state.

    Note that the runWithOptions method is called inside a try-catch block to force the error handling process.

    access

    public

    Parameters

    Returns Promise<void>

  • runAsScheduler(): Promise<void>
  • This method is the entry point of this scheduler. Due to the usage of the Cron decorator, and the implementation the nest backend runtime is able to discover this when the discovery scope is enabled.



    This scheduler is registered to run every 2 minute.

    see

    BaseCommand

    access

    public

    async

    Returns Promise<void>

  • synchronizeStateData(): Promise<void>
  • Synchronize on-memory state of this scheduler with the database persited state.

    If persisted state doesn't existed, update memory with default values so they can be used to construct a new state which will be saved to the database.

    access

    private

    async

    Returns Promise<void>

  • usage(): string
  • This method prints usage information to the command line and is used by nest-commander to print a correctly formatted help message.

    Note that usage methods can be overwritten but must always print a standard command line signature.

    access

    public

    Returns string

Generated using TypeDoc