Class Network


class Network extends BaseNetwork<Network,AccountId,Node>
Internal utility class.
  • Field Details

    • addressBook

      @Nullable Map<AccountId,NodeAddress> addressBook
      The protobuf address book converted into a map of node account IDs to NodeAddress This variable is package private so tests can use it
  • Method Details

    • forNetwork

      static Network forNetwork(ExecutorService executor, Map<String,AccountId> network)
      Create a network.
      Parameters:
      executor - the executor service
      network - the network records
      Returns:
      the new network
    • forMainnet

      static Network forMainnet(ExecutorService executor)
      Create a mainnet network.
      Parameters:
      executor - the executor service
      Returns:
      the new mainnet network
    • forTestnet

      static Network forTestnet(ExecutorService executor)
      Create a testnet network.
      Parameters:
      executor - the executor service
      Returns:
      the new testnet network
    • forPreviewnet

      static Network forPreviewnet(ExecutorService executor)
      Create a previewnet network.
      Parameters:
      executor - the executor service
      Returns:
      the new previewnet network
    • isVerifyCertificates

      boolean isVerifyCertificates()
      Are certificates being verified?
      Returns:
      are certificates being verified
    • setVerifyCertificates

      Network setVerifyCertificates(boolean verifyCertificates)
      Assign the desired verify certificate status.
      Parameters:
      verifyCertificates - the desired status
      Returns:
      this
    • setLedgerId

      Network setLedgerId(@Nullable LedgerId ledgerId)
      Description copied from class: BaseNetwork
      Set the new LedgerId for this network. LedgerIds are used for TLS certificate checking and entity ID checksum validation.
      Overrides:
      setLedgerId in class BaseNetwork<Network,AccountId,Node>
      Parameters:
      ledgerId - the ledger id
      Returns:
      this
    • setAddressBook

      void setAddressBook(NodeAddressBook addressBook)
    • addressBookToNetwork

      static HashMap<String,AccountId> addressBookToNetwork(Collection<NodeAddress> addressBook)
    • readAddressBookResource

      static Map<AccountId,NodeAddress> readAddressBookResource(String fileName)
      Import an address book.
      Parameters:
      fileName - the file name
      Returns:
      the list of address book records
    • getNetwork

      Map<String,AccountId> getNetwork()
      Extract the of network records.
      Returns:
      list of network records
    • createNodeFromNetworkEntry

      protected Node createNodeFromNetworkEntry(Map.Entry<String,AccountId> entry)
      Specified by:
      createNodeFromNetworkEntry in class BaseNetwork<Network,AccountId,Node>
    • getNodeAccountIdsForExecute

      List<AccountId> getNodeAccountIdsForExecute() throws InterruptedException
      Pick 1/3 of the nodes sorted by health and expected delay from the network. This is used by Query and Transaction for selecting node AccountId's.
      Returns:
      List<AccountId>
      Throws:
      InterruptedException
    • setMaxNodesPerRequest

      Network setMaxNodesPerRequest(int maxNodesPerRequest)
      Assign the maximum nodes to be returned for each request.
      Parameters:
      maxNodesPerRequest - the desired number of nodes
      Returns:
      this
    • getNumberOfNodesForRequest

      int getNumberOfNodesForRequest()
      Extract the number of nodes for each request.
      Returns:
      the number of nodes for each request
    • setTransportSecurity

      Network setTransportSecurity(boolean transportSecurity) throws InterruptedException
      Enable or disable transport security (TLS).
      Parameters:
      transportSecurity - should transport security be enabled
      Returns:
      this
      Throws:
      InterruptedException - when a thread is interrupted while it's waiting, sleeping, or otherwise occupied