Class Network

Hierarchy

  • Network

Methods

  • 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 [[DataModel.Network | Network]] resources and utilizes a system of [[DataModel.NetworkGenealogy | 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?: IncludeSettings;
      }

    Returns Promise<(undefined | Resources.IdObject<"networks">)[]>

  • Fetch blocks for given transaction hashes for the connected blockchain and load relevant resources into @truffle/db in order to link with existing records.

    See [[includeBlocks]] for more detail.

    Parameters

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

    Returns Promise<(undefined | Resources.IdObject<"networks">)[]>

Resource accessors

  • get genesis(): NetworkResource
  • Network resource ([[DataModel.Network | Resources.Resource<"networks">]]) representing the genesis block for the connected blockchain.

    Returns NetworkResource

  • get knownLatest(): NetworkResource
  • Network resource ([[DataModel.Network | Resources.Resource<"networks">]]) representing the latest known block for the connected blockchain.

    After [[initialize | Network.initialize()]], [[includeLatest]], [[includeBlocks]], and [[includeTransactions]], by default this value will be computed (or re-computed) based on inputs as well as queried records in @truffle/db already. Use skipKnownLatest option in [[IncludeSettings]] to update based only on existing known latest and additional inputs.

    Returns NetworkResource

Generated using TypeDoc