Options
All
  • Public
  • Public/Protected
  • All
Menu

Takes blocks output from implementations of AbstractActionReader and processes their actions through Updaters and Effects. Pass an object exposing a persistence API as state in the handleWithState method. Persist and retrieve information about the last block processed with updateIndexState and loadIndexState.

Hierarchy

Index

Constructors

constructor

Properties

Protected effects

effects: Effect[]

Protected lastProcessedBlockHash

lastProcessedBlockHash: string = ""

Protected lastProcessedBlockNumber

lastProcessedBlockNumber: number = 0

Protected updaters

updaters: Updater[]

Methods

Protected handleActions

  • handleActions(state: any, block: Block, context: any, isReplay: boolean): Promise<void>

handleBlock

  • handleBlock(block: Block, isRollback: boolean, isFirstBlock: boolean, isReplay?: boolean): Promise<[boolean, number]>
  • Receive block, validate, and handle actions with updaters and effects

    Parameters

    • block: Block
    • isRollback: boolean
    • isFirstBlock: boolean
    • Default value isReplay: boolean = false

    Returns Promise<[boolean, number]>

Protected Abstract handleWithState

  • handleWithState(handle: function): Promise<void>
  • Calls handleActions with the appropriate state passed by calling the handle parameter function. Optionally, pass in a context object as a second parameter.

    Parameters

    • handle: function
        • (state: any, context?: any): void
        • Parameters

          • state: any
          • Optional context: any

          Returns void

    Returns Promise<void>

Protected Abstract loadIndexState

  • Returns a promise for the lastProcessedBlockNumber and lastProcessedBlockHash meta state, coinciding with the block that has just been processed. These are the same values written by updateIndexState().

    Returns Promise<IndexState>

    A promise that resolves to an IndexState

Protected Abstract rollbackTo

  • rollbackTo(blockNumber: number): Promise<void>
  • Will run when a rollback block number is passed to handleActions. Implement this method to handle reversing actions full blocks at a time, until the last applied block is the block number passed to this method. If replay is true, effects should not be processed

    Parameters

    • blockNumber: number

    Returns Promise<void>

Protected runEffects

  • runEffects(state: any, block: Block, context: any): void

Protected runUpdaters

  • runUpdaters(state: any, block: Block, context: any): Promise<void>

Protected Abstract updateIndexState

  • updateIndexState(state: any, block: Block, isReplay: boolean, context?: any): Promise<void>
  • Updates the lastProcessedBlockNumber and lastProcessedBlockHash meta state, coinciding with the block that has just been processed. These are the same values read by updateIndexState().

    Parameters

    • state: any
    • block: Block
    • isReplay: boolean
    • Optional context: any

    Returns Promise<void>