Options
All
  • Public
  • Public/Protected
  • All
Menu

Class to get blocks by blockNumber. It uses cache to avoid unnecessary requests.

example

const getBlocksManager = new GetBlocksManager(); const blocks = await getBlocksManager.getBlocks(web3, blockNumbers);

Hierarchy

Index

Constructors

Properties

cachedBlocks: Record<number, BlockTransactionObject> = {}

Cache for blocks.

Methods

  • executeBatchCalls<T>(web3: default, calls: TWeb3Call<T>[]): Promise<T[]>
  • executeBatchCalls is supposed to decrease calls to blockchain. It only sends one request and returns data from each call.

    Type Parameters

    • T

    Parameters

    • web3: default

      web3 instance

    • calls: TWeb3Call<T>[]

      web3 calls

    Returns Promise<T[]>

    array of return values from web3 calls

  • getBlocks(web3: default, blockNumbers: number[]): Promise<BlockTransactionObject[]>
  • getBlocksFromCache(blocksNumbers: number[]): BlockTransactionObject[]
  • log(...args: any[]): void
  • optimizeCachedBlocks(newBlocksCount: number): void
  • saveBlocksToCache(blocks: BlockTransactionObject[]): void

Generated using TypeDoc