Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Network

Hierarchy

  • Network

Index

Methods

includeBlocks

  • Load relevant resources into @truffle/db for a given set of blocks for the connected blockchain. Provide either height or height and hash for each block; this method will fetch hashes for block heights for any blocks provided without hash.

    This method queries @truffle/db for existing resources to build a sparse model of the relationships between blockchain networks. This mechanism identifies blockchain networks as Network resources and utilizes a system of NetworkGenealogy resources to identify blocks as being ancestor or descendant to one another. This allows @truffle/db to maintain a continuous view of any particular blockchain while respecting that networks may hard-fork or re-organize in the future.

    To complete these linkages, this method alternately queries @truffle/db for candidate ancestors/descendants and fetches actual records from the connected blockchain itself until it finds an optimal match. This process operates in logarithmic time and logarithmic space based on the number of existing known blocks in the system and the number of blocks provided as input.

    Note: Despite optimizing for speed and memory usage, this process can nonetheless still perform a significant number of network requests and internal database reads. Although this system has been tested to perform satisfactorily against tens of thousands of blocks with multiple hardfork scenarios, this abstraction provides a few IncludeSettings to migitate unforeseen issues.

    This returns an IdObject for each DataModel.Network resource added in the process. Return values are ordered so that indexes of returned IDs correspond to indexes of provided blocks; any blocks that fail to load successfully will correspond to values of null or undefined in the resulting array.

    Type parameters

    Parameters

    • options: { blocks: (undefined | Block)[]; settings?: undefined | IncludeSettings }
      • blocks: (undefined | Block)[]
      • Optional settings?: undefined | IncludeSettings

    Returns Promise<(undefined | IdObject<Collections, "networks", Network> | IdObject<Collections, "networks", SavedInput<Collections, "networks">>)[]>

includeLatest

includeTransactions

Resource accessors

genesis

  • get genesis(): Pick<Network, "id" | "name" | "networkId" | "historicBlock">

knownLatest

  • get knownLatest(): Pick<Network, "id" | "name" | "networkId" | "historicBlock">

Generated using TypeDoc