Options
All
  • Public
  • Public/Protected
  • All
Menu

Reads blocks from a blockchain, outputting normalized Block objects.

Hierarchy

Index

Constructors

constructor

  • new AbstractActionReader(startAtBlock?: number, onlyIrreversible?: boolean, maxHistoryLength?: number): AbstractActionReader

Properties

Protected blockHistory

blockHistory: Block[] = []

Protected currentBlockData

currentBlockData: Block | null = null

currentBlockNumber

currentBlockNumber: number

headBlockNumber

headBlockNumber: number = 0

isFirstBlock

isFirstBlock: boolean = true

Protected maxHistoryLength

maxHistoryLength: number

Protected onlyIrreversible

onlyIrreversible: boolean

startAtBlock

startAtBlock: number

Methods

Abstract getBlock

  • getBlock(blockNumber: number): Promise<Block>

Abstract getHeadBlockNumber

  • getHeadBlockNumber(): Promise<number>

nextBlock

  • nextBlock(): Promise<[Block, boolean]>
  • Loads the next block with chainInterface after validating, updating all relevant state. If block fails validation, rollback will be called, and will update state to last block unseen.

    Returns Promise<[Block, boolean]>

rollback

  • rollback(): Promise<void>
  • Incrementally rolls back reader state one block at a time, comparing the blockHistory with newly fetched blocks. Rollback is finished when either the current block's previous hash matches the previous block's hash, or when history is exhausted.

    Returns Promise<void>

Protected rollbackExhausted

  • rollbackExhausted(): void
  • When history is exhausted in rollback(), this is run to handle the situation. If left unimplemented, then only instantiate with onlyIrreversible set to true.

    Returns void

seekToBlock

  • seekToBlock(blockNumber: number): Promise<void>