Package org.hyperledger.fabric.gateway
Interface Network
-
public interface NetworkA Network object represents the set of peers in a Fabric network (channel). Applications should get a Network instance from a Gateway using theGateway.getNetwork(String)method.The Network object provides the ability for applications to:
- Obtain a specific smart contract deployed to the network using
getContract(String), in order to submit and evaluate transactions for that smart contract. - Listen to new block events using
addBlockListener(Consumer). - Replay previous block events using
addBlockListener(long, Consumer).
- Obtain a specific smart contract deployed to the network using
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent>addBlockListener(long startBlock, java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)Add a listener to replay block events from the network.java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent>addBlockListener(java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)Add a listener to receive block events from the network.java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent>addBlockListener(Checkpointer checkpointer, java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)Add a listener to receive block events from the network with checkpointing.CommitListeneraddCommitListener(CommitListener listener, java.util.Collection<org.hyperledger.fabric.sdk.Peer> peers, java.lang.String transactionId)Add a listener to receive transaction commit and peer disconnect events for a set of peers.org.hyperledger.fabric.sdk.ChannelgetChannel()Get the low-level chanel object associated with this network.ContractgetContract(java.lang.String chaincodeId)Get an instance of a contract on the current network.ContractgetContract(java.lang.String chaincodeId, java.lang.String name)Get an instance of a contract on the current network.GatewaygetGateway()Get a reference to the owning Gateway connection.voidremoveBlockListener(java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)Removes a previously added block listener.voidremoveCommitListener(CommitListener listener)Removes a previously added transaction commit listener.
-
-
-
Method Detail
-
getContract
Contract getContract(java.lang.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(java.lang.String chaincodeId, java.lang.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
java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(java.util.function.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
java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(Checkpointer checkpointer, java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener) throws java.io.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:
java.io.IOException- if an error occurs establishing checkpointing.GatewayRuntimeException- if an underlying infrastructure failure occurs.
-
addBlockListener
java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> addBlockListener(long startBlock, java.util.function.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(java.util.function.Consumer<org.hyperledger.fabric.sdk.BlockEvent> listener)
Removes a previously added block listener.- Parameters:
listener- A block listener.
-
addCommitListener
CommitListener addCommitListener(CommitListener listener, java.util.Collection<org.hyperledger.fabric.sdk.Peer> peers, java.lang.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.
-
-