Interface Network


public interface Network
A Network object represents the set of peers in a Fabric network (channel). Applications should get a Network instance from a Gateway using the Gateway.getNetwork(String) method.

The Network object provides the ability for applications to:

See Also:
  • Method Details

    • getContract

      Contract getContract(String chaincodeId)
      Get an instance of a contract on the current network.
      Parameters:
      chaincodeId - The name of the chaincode that implements the smart contract.
      Returns:
      The contract object.
    • getContract

      Contract getContract(String chaincodeId, String name)
      Get an instance of a contract on the current network. If the chaincode instance contains more than one smart contract class (available using the latest chaincode programming model), then an individual class can be selected.
      Parameters:
      chaincodeId - The name of the chaincode that implements the smart contract.
      name - The class name of the smart contract within the chaincode.
      Returns:
      The contract object.
    • getGateway

      Gateway getGateway()
      Get a reference to the owning Gateway connection.
      Returns:
      The owning gateway.
    • getChannel

      org.hyperledger.fabric.sdk.Channel getChannel()
      Get the low-level chanel object associated with this network.
      Returns:
      A channel.
    • addBlockListener

      Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)
      Add a listener to receive block events from the network. Events are received in order and without duplication.
      Parameters:
      listener - A block listener.
      Returns:
      The block listener argument.
    • addBlockListener

      Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(Checkpointer checkpointer, Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener) throws IOException
      Add a listener to receive block events from the network with checkpointing. Re-adding a listener with the same checkpointer on subsequent application invocations will resume listening from the previous block position. Events are received in order and without duplication.
      Parameters:
      checkpointer - Checkpointer to persist block position.
      listener - A block listener.
      Returns:
      The block listener argument.
      Throws:
      IOException - if an error occurs establishing checkpointing.
      GatewayRuntimeException - if an underlying infrastructure failure occurs.
    • addBlockListener

      Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(long startBlock, Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)
      Add a listener to replay block events from the network. Events are received in order and without duplication.
      Parameters:
      startBlock - The number of the block from which events should be replayed.
      listener - A block listener.
      Returns:
      The block listener argument.
      Throws:
      GatewayRuntimeException - if an underlying infrastructure failure occurs.
    • removeBlockListener

      void removeBlockListener(Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)
      Removes a previously added block listener.
      Parameters:
      listener - A block listener.
    • addCommitListener

      CommitListener addCommitListener(CommitListener listener, Collection<org.hyperledger.fabric.sdk.Peer> peers, String transactionId)
      Add a listener to receive transaction commit and peer disconnect events for a set of peers.
      Parameters:
      listener - A transaction commit listener.
      peers - The peers from which to receive events.
      transactionId - A transaction ID.
      Returns:
      The transaction commit listener argument.
    • removeCommitListener

      void removeCommitListener(CommitListener listener)
      Removes a previously added transaction commit listener.
      Parameters:
      listener - A block listener.