Package org.hyperledger.fabric.sdk
Class Channel
java.lang.Object
org.hyperledger.fabric.sdk.Channel
- All Implemented Interfaces:
Serializable
The class representing a channel with which the client SDK interacts.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Options for doing service discovery.static class
NofEvents may be used with @seeChannel.TransactionOptions.nOfEvents(NOfEvents)
to control how reporting Peer service events and Eventhubs will complete the future acknowledging the transaction has been seen by those Peers.static class
Options for the peer.static class
static interface
static interface
static class
static interface
static interface
static class
Additional metadata used by service discovery to find the endorsements needed.static class
TransactionOptions class can be used to change how the SDK processes the Transaction. -
Method Summary
Modifier and TypeMethodDescriptionaddOrderer
(Orderer orderer) Add an Orderer to this channel.Add a peer to the channeladdPeer
(Peer peer, Channel.PeerOptions peerOptions) Add a peer to the channelbyte[]
byte[]
getChannelConfigurationBytes
(User userContext) Channel Configuration bytes.byte[]
getChannelConfigurationBytes
(User userContext, Orderer orderer) Get channel configuration from a specific Ordererbyte[]
getChannelConfigurationBytes
(User userContext, Peer peer) Get channel configuration from a specific peergetConfigUpdateAnchorPeers
(Peer peer, User userContext, Collection<String> peersToAdd, Collection<String> peersToRemove) Get a channel configuration update to add or remove peers.Collection of discovered chaincode names.getName()
Get the channel namegetOrderersForOrganization
(String mspid) Get orderers that belong to an organization from the organization's MSPID These values may not be available till after the channel is initialized.Collection of strings which are the MSPIDs of all the orderer organization added.getPeers()
Get the peers for this channel.getPeers
(EnumSet<Peer.PeerRole> roles) Get the peers for this channel.getPeersForOrganization
(String mspid) Get peers that belong to an organization from the organization's MSPID These values may not be available till after the channel is initialized.getPeersOptions
(Peer peer) Collection of strings which are the MSPIDs of all the peer organization added.Get current service discovery orderer addition override.Get current service discovery peer addition override.byte[]
getUpdateChannelConfigurationSignature
(UpdateChannelConfiguration updateChannelConfiguration, User signer) Get signed byes of the update channel.Initialize the Channel.boolean
Is channel initialized.boolean
Is the channel shutdown.joinPeer
(Orderer orderer, Peer peer, Channel.PeerOptions peerOptions) Join peer to channelJoin the peer to the channel.joinPeer
(Peer peer, Channel.PeerOptions peerOptions) lifecycleQueryChaincodeDefinition
(QueryLifecycleQueryChaincodeDefinitionRequest queryLifecycleQueryChaincodeDefinitionRequest, Collection<Peer> peers) lifecycleQueryChaincodeDefinition get definition of chaincode.lifecycleQueryChaincodeDefinitions
(LifecycleQueryChaincodeDefinitionsRequest proposalRequest, Collection<Peer> peers) Query namespaces.org.hyperledger.fabric.sdk.transaction.TransactionContext
Create a new transaction context based on the client user context.queryBlockByHash
(byte[] blockHash) query this channel for a Block by the block hash.queryBlockByHash
(byte[] blockHash, User userContext) query this channel for a Block by the block hash.queryBlockByHash
(Collection<Peer> peers, byte[] blockHash) Query a peer in this channel for a Block by the block hash.queryBlockByHash
(Collection<Peer> peers, byte[] blockHash, User userContext) Query a peer in this channel for a Block by the block hash.queryBlockByHash
(Peer peer, byte[] blockHash) Query a peer in this channel for a Block by the block hash.queryBlockByNumber
(long blockNumber) query this channel for a Block by the blockNumber.queryBlockByNumber
(long blockNumber, User userContext) query this channel for a Block by the blockNumber.queryBlockByNumber
(Collection<Peer> peers, long blockNumber) query a peer in this channel for a Block by the blockNumber This method may not be thread safe if client context is changed!queryBlockByNumber
(Collection<Peer> peers, long blockNumber, User userContext) query a peer in this channel for a Block by the blockNumberqueryBlockByNumber
(Peer peer, long blockNumber) Query a peer in this channel for a Block by the blockNumber This method may not be thread safe if client context is changed!queryBlockByNumber
(Peer peer, long blockNumber, User userContext) query a peer in this channel for a Block by the blockNumberquery this channel for a Block by a TransactionID contained in the block The request is tried on on each peer till successful.queryBlockByTransactionID
(String txID, User userContext) query this channel for a Block by a TransactionID contained in the block The request is sent to a random peer in the channelqueryBlockByTransactionID
(Collection<Peer> peers, String txID) query a peer in this channel for a Block by a TransactionID contained in the block This method may not be thread safe if client context is changed!queryBlockByTransactionID
(Collection<Peer> peers, String txID, User userContext) query a peer in this channel for a Block by a TransactionID contained in the blockqueryBlockByTransactionID
(Peer peer, String txID) query a peer in this channel for a Block by a TransactionID contained in the block This method may not be thread safe if client context is changed!queryBlockByTransactionID
(Peer peer, String txID, User userContext) query a peer in this channel for a Block by a TransactionID contained in the blockquery this channel for chain information.queryBlockchainInfo
(Collection<Peer> peers, User userContext) query for chain informationqueryBlockchainInfo
(Peer peer) query for chain information This method may not be thread safe if client context is changed!queryBlockchainInfo
(Peer peer, User userContext) query for chain informationqueryBlockchainInfo
(User userContext) query this channel for chain information.queryByChaincode
(QueryByChaincodeRequest queryByChaincodeRequest) Send Query proposalqueryByChaincode
(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers) Send Query proposalqueryCollectionsConfig
(String chaincodeName, Peer peer, User userContext) Get information on the collections used by the chaincode.List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo>
Query peer for chaincode that has been instantiated This method may not be thread safe if client context is changed!List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo>
queryInstantiatedChaincodes
(Peer peer, User userContext) Query peer for chaincode that has been instantiatedqueryTransactionByID
(String txID) Query this channel for a Fabric Transaction given its transactionID.queryTransactionByID
(String txID, User userContext) Query this channel for a Fabric Transaction given its transactionID.queryTransactionByID
(Collection<Peer> peers, String txID, User userContext) Query for a Fabric Transaction given its transactionIDqueryTransactionByID
(Peer peer, String txID) Query for a Fabric Transaction given its transactionID This method may not be thread safe if client context is changed!queryTransactionByID
(Peer peer, String txID, User userContext) Query for a Fabric Transaction given its transactionIDregisterBlockListener
(BlockingQueue<QueuedBlockEvent> blockEventQueue) Register a Queued block listener.registerBlockListener
(BlockingQueue<QueuedBlockEvent> blockEventQueue, long timeout, TimeUnit timeUnit) Register a Queued block listener.registerBlockListener
(BlockListener listener) Register a block listener.registerChaincodeEventListener
(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener) Register a chaincode event listener.void
removeOrderer
(Orderer orderer) void
removePeer
(Peer peer) Removes the peer connection from the channel.sendInstantiationProposal
(InstantiateProposalRequest instantiateProposalRequest) Deprecated.See new lifecycle chaincode management.sendInstantiationProposal
(InstantiateProposalRequest instantiateProposalRequest, Collection<Peer> peers) Deprecated.See new lifecycle chaincode management.sendLifecycleApproveChaincodeDefinitionForMyOrgProposal
(LifecycleApproveChaincodeDefinitionForMyOrgRequest lifecycleApproveChaincodeDefinitionForMyOrgRequest, Collection<Peer> peers) Approve chaincode to be run on this peer's organization.sendLifecycleApproveChaincodeDefinitionForMyOrgProposal
(LifecycleApproveChaincodeDefinitionForMyOrgRequest lifecycleApproveChaincodeDefinitionForMyOrgRequest, Peer peer) Approve chaincode to be run on this peer's organization.sendLifecycleCheckCommitReadinessRequest
(LifecycleCheckCommitReadinessRequest lifecycleCheckCommitReadinessRequest, Collection<Peer> peers) Query approval status for all organizations.sendLifecycleCommitChaincodeDefinitionProposal
(LifecycleCommitChaincodeDefinitionRequest lifecycleCommitChaincodeDefinitionRequest, Collection<Peer> peers) Commit chaincode final approval to run on all organizations that have approved.sendTransaction
(Collection<? extends ProposalResponse> proposalResponses) Send transaction to one of the orderers on the channel using the usercontext set on the client.sendTransaction
(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers) Send transaction to one of the specified orderers using the usercontext set on the client..sendTransaction
(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext) Send transaction to one of a specified set of orderers with the specified user context.sendTransaction
(Collection<? extends ProposalResponse> proposalResponses, Channel.TransactionOptions transactionOptions) Send transaction to one of a specified set of orderers with the specified user context.sendTransaction
(Collection<ProposalResponse> proposalResponses, User userContext) Send transaction to one of the orderers on the channel using a specific user context.sendTransactionProposal
(TransactionProposalRequest transactionProposalRequest) Send a transaction proposal.sendTransactionProposal
(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers) Send a transaction proposal to specific peers.sendTransactionProposalToEndorsers
(TransactionProposalRequest transactionProposalRequest, Channel.DiscoveryOptions discoveryOptions) Send a transaction proposal.sendUpgradeProposal
(UpgradeProposalRequest upgradeProposalRequest) Deprecated.See new Lifecycle chaincode management.sendUpgradeProposal
(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers) Deprecated.See new Lifecycle chaincode management.byte[]
Serialize channel to a byte array using Java serialization.void
serializeChannel
(File file) Serialize channel to a file using Java serialization.setSDEndorserSelector
(ServiceDiscovery.EndorsementSelector endorsementSelector) setSDOrdererAddition
(Channel.SDOrdererAddition sdOrdererAddition) Set service discovery orderer addition override.setSDPeerAddition
(Channel.SDPeerAddition sdPeerAddition) Set service discovery peer addition override.void
setServiceDiscoveryProperties
(Properties serviceDiscoveryProperties) void
shutdown
(boolean force) Shutdown the channel with all resources released.toString()
boolean
unregisterBlockListener
(String handle) Unregister a block listener.boolean
Unregister an existing chaincode event listener.void
updateChannelConfiguration
(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers) Update channel with specified channel configuration.void
updateChannelConfiguration
(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers) Update channel with specified channel configurationvoid
updateChannelConfiguration
(User userContext, UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers) Update channel with specified channel configuration
-
Method Details
-
toString
-
updateChannelConfiguration
public void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers) throws TransactionException, InvalidArgumentException Update channel with specified channel configuration. Note This is not a thread safe operation- Parameters:
updateChannelConfiguration
- Updated Channel configurationsigners
- signers- Throws:
TransactionException
InvalidArgumentException
-
updateChannelConfiguration
public void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers) throws TransactionException, InvalidArgumentException Update channel with specified channel configuration Note This is not a thread safe operation- Parameters:
updateChannelConfiguration
- Channel configurationsigners
- signersorderer
- The specific orderer to use.- Throws:
TransactionException
InvalidArgumentException
-
updateChannelConfiguration
public void updateChannelConfiguration(User userContext, UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers) throws TransactionException, InvalidArgumentException Update channel with specified channel configuration- Parameters:
userContext
- The specific user to use.updateChannelConfiguration
- Channel configurationsigners
- signersorderer
- The specific orderer to use.- Throws:
TransactionException
InvalidArgumentException
-
isInitialized
public boolean isInitialized()Is channel initialized.- Returns:
- true if the channel has been initialized.
-
getName
Get the channel name- Returns:
- The name of the channel
-
addPeer
Add a peer to the channel- Parameters:
peer
- The Peer to add.- Returns:
- Channel The current channel added.
- Throws:
InvalidArgumentException
-
addPeer
Add a peer to the channel- Parameters:
peer
- The Peer to add.peerOptions
- seePeer.PeerRole
- Returns:
- Channel The current channel added.
- Throws:
InvalidArgumentException
-
getPeersForOrganization
Get peers that belong to an organization from the organization's MSPID These values may not be available till after the channel is initialized.- Parameters:
mspid
- The organizaiions MSPID- Returns:
- A collection of Peers that belong to the organization with that mspid.
- Throws:
InvalidArgumentException
-
getPeersOrganizationMSPIDs
Collection of strings which are the MSPIDs of all the peer organization added. These values may not be available till after the channel is initialized.- Returns:
- The collection of mspids
-
joinPeer
Join the peer to the channel. The peer is added with all roles seeChannel.PeerOptions
- Parameters:
peer
- the peer to join the channel.- Returns:
- Throws:
ProposalException
-
joinPeer
- Parameters:
peer
- the peer to join the channel.peerOptions
- seeChannel.PeerOptions
- Returns:
- Throws:
ProposalException
-
joinPeer
public Channel joinPeer(Orderer orderer, Peer peer, Channel.PeerOptions peerOptions) throws ProposalException Join peer to channel- Parameters:
orderer
- The orderer to get the genesis block.peer
- the peer to join the channel.peerOptions
- seeChannel.PeerOptions
- Returns:
- Throws:
ProposalException
-
removePeer
Removes the peer connection from the channel. This does NOT unjoin the peer from from the channel. Fabric does not support that at this time -- maybe some day, but not today- Parameters:
peer
-- Throws:
InvalidArgumentException
-
addOrderer
Add an Orderer to this channel.- Parameters:
orderer
- the orderer to add.- Returns:
- this channel.
- Throws:
InvalidArgumentException
-
removeOrderer
- Throws:
InvalidArgumentException
-
getOrderersForOrganization
Get orderers that belong to an organization from the organization's MSPID These values may not be available till after the channel is initialized.- Parameters:
mspid
- The organizaiions MSPID- Returns:
- A collection of Orderers that belong to the organization with that mspid.
- Throws:
InvalidArgumentException
-
getOrderersOrganizationMSPIDs
Collection of strings which are the MSPIDs of all the orderer organization added. These values may not be available till after the channel is initialized.- Returns:
- The collection of mspids
-
getPeersOptions
-
getPeers
Get the peers for this channel.- Returns:
- the peers.
-
getPeers
Get the peers for this channel.- Returns:
- the peers.
-
initialize
Initialize the Channel. Starts the channel. event hubs will connect.- Returns:
- this channel.
- Throws:
InvalidArgumentException
TransactionException
-
getServiceDiscoveryProperties
-
setServiceDiscoveryProperties
-
setSDOrdererAddition
Set service discovery orderer addition override.Any service discovery properties
setServiceDiscoveryProperties(Properties)
should be set before calling this.- Parameters:
sdOrdererAddition
-- Returns:
-
getSDOrdererAddition
Get current service discovery orderer addition override.Any service discovery properties
setServiceDiscoveryProperties(Properties)
should be set before calling this.- Returns:
- SDOrdererAddition
-
setSDPeerAddition
Set service discovery peer addition override.Any service discovery properties
setServiceDiscoveryProperties(Properties)
should be set before calling this.- Parameters:
sdPeerAddition
-- Returns:
-
getSDPeerAddition
Get current service discovery peer addition override.Any service discovery properties
setServiceDiscoveryProperties(Properties)
should be set before calling this.- Returns:
- SDOrdererAddition
-
isShutdown
public boolean isShutdown()Is the channel shutdown.- Returns:
- return true if the channel is shutdown.
-
getUpdateChannelConfigurationSignature
public byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer) throws InvalidArgumentException Get signed byes of the update channel.- Parameters:
updateChannelConfiguration
-signer
-- Returns:
- Throws:
InvalidArgumentException
-
getConfigUpdateAnchorPeers
public Channel.AnchorPeersConfigUpdateResult getConfigUpdateAnchorPeers(Peer peer, User userContext, Collection<String> peersToAdd, Collection<String> peersToRemove) throws Exception Get a channel configuration update to add or remove peers. If both peersToAdd AND peersToRemove are null then only the current anchor peers are reported with @seeChannel.AnchorPeersConfigUpdateResult.getCurrentPeers()
- Parameters:
peer
- peer to use to the channel configuration from.userContext
- The usercontext to use.peersToAdd
- Peers to add as Host:Port peer1.org2.com:7022peersToRemove
- Peers to remove as Host:Port peer1.org2.com:7022- Returns:
- The AnchorPeersConfigUpdateResult @see
Channel.AnchorPeersConfigUpdateResult
- Throws:
Exception
-
getChannelConfigurationBytes
public byte[] getChannelConfigurationBytes(User userContext, Orderer orderer) throws InvalidArgumentException, TransactionException Get channel configuration from a specific Orderer- Parameters:
userContext
- The user to sign the action.orderer
- To retrieve the configuration from.- Returns:
- Configuration block.
- Throws:
InvalidArgumentException
TransactionException
-
getChannelConfigurationBytes
public byte[] getChannelConfigurationBytes(User userContext, Peer peer) throws InvalidArgumentException, TransactionException Get channel configuration from a specific peer- Parameters:
userContext
- The user to sign the action.peer
- To retrieve the configuration from.- Returns:
- Configuration block.
- Throws:
InvalidArgumentException
TransactionException
-
getChannelConfigurationBytes
-
getChannelConfigurationBytes
public byte[] getChannelConfigurationBytes(User userContext) throws InvalidArgumentException, TransactionException Channel Configuration bytes. Bytes that can be used with configtxlator tool to upgrade the channel. If Peers exist on the channel config block will be retrieved from them. If only Orderers exist the configblock is retrieved from them. Convert to Json for editing with:<p> curl -v POST --data-binary @fooConfig http://host/protolator/decode/common.Config <p>
See http://hyperledger-fabric.readthedocs.io/en/latest/configtxlator.html- Returns:
- Channel configuration bytes.
- Throws:
TransactionException
InvalidArgumentException
-
getOrderers
-
sendInstantiationProposal
@Deprecated public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest) throws InvalidArgumentException, ProposalException Deprecated.See new lifecycle chaincode management.LifecycleInstallChaincodeRequest
Send instantiate request to the channel. Chaincode is created and initialized.- Parameters:
instantiateProposalRequest
- send instantiate chaincode proposal request.- Returns:
- Collections of proposal responses
- Throws:
InvalidArgumentException
ProposalException
-
sendInstantiationProposal
@Deprecated public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Deprecated.See new lifecycle chaincode management.LifecycleInstallChaincodeRequest
Send instantiate request to the channel. Chaincode is created and initialized.- Parameters:
instantiateProposalRequest
-peers
-- Returns:
- responses from peers.
- Throws:
InvalidArgumentException
ProposalException
-
newTransactionContext
public org.hyperledger.fabric.sdk.transaction.TransactionContext newTransactionContext()Create a new transaction context based on the client user context. The transaction context can be set on aTransactionRequest
prior to callingsendTransactionProposal(TransactionProposalRequest)
so that the caller can know the transaction ID in advance.- Returns:
- A transaction context.
-
sendUpgradeProposal
@Deprecated public Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest) throws ProposalException, InvalidArgumentException Deprecated.See new Lifecycle chaincode management.sendLifecycleApproveChaincodeDefinitionForMyOrgProposal(LifecycleApproveChaincodeDefinitionForMyOrgRequest, Peer)
Send Upgrade proposal proposal to upgrade chaincode to a new version.- Parameters:
upgradeProposalRequest
-- Returns:
- Collection of proposal responses.
- Throws:
ProposalException
InvalidArgumentException
-
sendUpgradeProposal
@Deprecated public Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Deprecated.See new Lifecycle chaincode management.sendLifecycleApproveChaincodeDefinitionForMyOrgProposal(LifecycleApproveChaincodeDefinitionForMyOrgRequest, Peer)
Send Upgrade proposal proposal to upgrade chaincode to a new version.- Parameters:
upgradeProposalRequest
-peers
- the specific peers to send to.- Returns:
- Collection of proposal responses.
- Throws:
ProposalException
InvalidArgumentException
-
queryBlockByHash
public BlockInfo queryBlockByHash(byte[] blockHash) throws InvalidArgumentException, ProposalException query this channel for a Block by the block hash. The request is retried on each peer on the channel till successful. This method may not be thread safe if client context is changed!- Parameters:
blockHash
- the hash of the Block in the chain- Returns:
- the
BlockInfo
with the given block Hash - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByHash
public BlockInfo queryBlockByHash(byte[] blockHash, User userContext) throws InvalidArgumentException, ProposalException query this channel for a Block by the block hash. The request is tried on multiple peers.- Parameters:
blockHash
- the hash of the Block in the chainuserContext
- the user context.- Returns:
- the
BlockInfo
with the given block Hash - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByHash
public BlockInfo queryBlockByHash(Peer peer, byte[] blockHash) throws InvalidArgumentException, ProposalException Query a peer in this channel for a Block by the block hash. This method may not be thread safe if client context is changed!- Parameters:
peer
- the Peer to query.blockHash
- the hash of the Block in the chain.- Returns:
- the
BlockInfo
with the given block Hash - Throws:
InvalidArgumentException
- if the channel is shutdown or any of the arguments are not valid.ProposalException
- if an error occurred processing the query.
-
queryBlockByHash
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash) throws InvalidArgumentException, ProposalException Query a peer in this channel for a Block by the block hash. Each peer is tried until successful response. This method may not be thread safe if client context is changed!- Parameters:
peers
- the Peers to query.blockHash
- the hash of the Block in the chain.- Returns:
- the
BlockInfo
with the given block Hash - Throws:
InvalidArgumentException
- if the channel is shutdown or any of the arguments are not valid.ProposalException
- if an error occurred processing the query.
-
queryBlockByHash
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash, User userContext) throws InvalidArgumentException, ProposalException Query a peer in this channel for a Block by the block hash.- Parameters:
peers
- the Peers to query.blockHash
- the hash of the Block in the chain.userContext
- the user context- Returns:
- the
BlockInfo
with the given block Hash - Throws:
InvalidArgumentException
- if the channel is shutdown or any of the arguments are not valid.ProposalException
- if an error occurred processing the query.
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(long blockNumber) throws InvalidArgumentException, ProposalException query this channel for a Block by the blockNumber. The request is retried on all peers till successful This method may not be thread safe if client context is changed!- Parameters:
blockNumber
- index of the Block in the chain- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(long blockNumber, User userContext) throws InvalidArgumentException, ProposalException query this channel for a Block by the blockNumber. The request is sent to a random peer in the channel.- Parameters:
blockNumber
- index of the Block in the chainuserContext
- the user context to be used.- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(Peer peer, long blockNumber) throws InvalidArgumentException, ProposalException Query a peer in this channel for a Block by the blockNumber This method may not be thread safe if client context is changed!- Parameters:
peer
- the peer to send the request toblockNumber
- index of the Block in the chain- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(Peer peer, long blockNumber, User userContext) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by the blockNumber- Parameters:
peer
- the peer to send the request toblockNumber
- index of the Block in the chainuserContext
- the user context.- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(Collection<Peer> peers, long blockNumber) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by the blockNumber This method may not be thread safe if client context is changed!- Parameters:
peers
- the peers to try and send the request toblockNumber
- index of the Block in the chain- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByNumber
public BlockInfo queryBlockByNumber(Collection<Peer> peers, long blockNumber, User userContext) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by the blockNumber- Parameters:
peers
- the peers to try and send the request toblockNumber
- index of the Block in the chainuserContext
- the user context to use.- Returns:
- the
BlockInfo
with the given blockNumber - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(String txID) throws InvalidArgumentException, ProposalException query this channel for a Block by a TransactionID contained in the block The request is tried on on each peer till successful. This method may not be thread safe if client context is changed!- Parameters:
txID
- the transactionID to query on- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(String txID, User userContext) throws InvalidArgumentException, ProposalException query this channel for a Block by a TransactionID contained in the block The request is sent to a random peer in the channel- Parameters:
txID
- the transactionID to query onuserContext
- the user context.- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(Peer peer, String txID) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by a TransactionID contained in the block This method may not be thread safe if client context is changed!- Parameters:
peer
- the peer to send the request totxID
- the transactionID to query on- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(Peer peer, String txID, User userContext) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by a TransactionID contained in the block- Parameters:
peer
- the peer to send the request totxID
- the transactionID to query onuserContext
- the user context.- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(Collection<Peer> peers, String txID) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by a TransactionID contained in the block This method may not be thread safe if client context is changed!- Parameters:
peers
- the peers to try to send the request to.txID
- the transactionID to query on- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockByTransactionID
public BlockInfo queryBlockByTransactionID(Collection<Peer> peers, String txID, User userContext) throws InvalidArgumentException, ProposalException query a peer in this channel for a Block by a TransactionID contained in the block- Parameters:
peers
- the peer to try to send the request totxID
- the transactionID to query onuserContext
- the user context.- Returns:
- the
BlockInfo
for the Block containing the transaction - Throws:
InvalidArgumentException
ProposalException
-
queryBlockchainInfo
query this channel for chain information. The request is sent to a random peer in the channel This method may not be thread safe if client context is changed!- Returns:
- a
BlockchainInfo
object containing the chain info requested - Throws:
InvalidArgumentException
ProposalException
-
queryBlockchainInfo
public BlockchainInfo queryBlockchainInfo(User userContext) throws ProposalException, InvalidArgumentException query this channel for chain information. The request is sent to a random peer in the channel- Parameters:
userContext
- the user context to use.- Returns:
- a
BlockchainInfo
object containing the chain info requested - Throws:
InvalidArgumentException
ProposalException
-
queryBlockchainInfo
public BlockchainInfo queryBlockchainInfo(Peer peer) throws ProposalException, InvalidArgumentException query for chain information This method may not be thread safe if client context is changed!- Parameters:
peer
- The peer to send the request to- Returns:
- a
BlockchainInfo
object containing the chain info requested - Throws:
InvalidArgumentException
ProposalException
-
queryBlockchainInfo
public BlockchainInfo queryBlockchainInfo(Peer peer, User userContext) throws ProposalException, InvalidArgumentException query for chain information- Parameters:
peer
- The peer to send the request touserContext
- the user context to use.- Returns:
- a
BlockchainInfo
object containing the chain info requested - Throws:
InvalidArgumentException
ProposalException
-
queryBlockchainInfo
public BlockchainInfo queryBlockchainInfo(Collection<Peer> peers, User userContext) throws ProposalException, InvalidArgumentException query for chain information- Parameters:
peers
- The peers to try send the request.userContext
- the user context.- Returns:
- a
BlockchainInfo
object containing the chain info requested - Throws:
InvalidArgumentException
ProposalException
-
queryTransactionByID
public TransactionInfo queryTransactionByID(String txID) throws ProposalException, InvalidArgumentException Query this channel for a Fabric Transaction given its transactionID. The request is sent to a random peer in the channel. This method may not be thread safe if client context is changed!- Parameters:
txID
- the ID of the transaction- Returns:
- a
TransactionInfo
- Throws:
ProposalException
InvalidArgumentException
-
queryTransactionByID
public TransactionInfo queryTransactionByID(String txID, User userContext) throws ProposalException, InvalidArgumentException Query this channel for a Fabric Transaction given its transactionID. The request is sent to a random peer in the channel. This method may not be thread safe if client context is changed!- Parameters:
txID
- the ID of the transactionuserContext
- the user context used.- Returns:
- a
TransactionInfo
- Throws:
ProposalException
InvalidArgumentException
-
queryTransactionByID
public TransactionInfo queryTransactionByID(Peer peer, String txID) throws ProposalException, InvalidArgumentException Query for a Fabric Transaction given its transactionID This method may not be thread safe if client context is changed!- Parameters:
txID
- the ID of the transactionpeer
- the peer to send the request to- Returns:
- a
TransactionInfo
- Throws:
ProposalException
InvalidArgumentException
-
queryTransactionByID
public TransactionInfo queryTransactionByID(Peer peer, String txID, User userContext) throws ProposalException, InvalidArgumentException Query for a Fabric Transaction given its transactionID- Parameters:
peer
- the peer to send the request totxID
- the ID of the transactionuserContext
- the user context- Returns:
- a
TransactionInfo
- Throws:
ProposalException
InvalidArgumentException
-
queryTransactionByID
public TransactionInfo queryTransactionByID(Collection<Peer> peers, String txID, User userContext) throws ProposalException, InvalidArgumentException Query for a Fabric Transaction given its transactionID- Parameters:
txID
- the ID of the transactionpeers
- the peers to try to send the request.userContext
- the user context- Returns:
- a
TransactionInfo
- Throws:
ProposalException
InvalidArgumentException
-
sendLifecycleApproveChaincodeDefinitionForMyOrgProposal
public LifecycleApproveChaincodeDefinitionForMyOrgProposalResponse sendLifecycleApproveChaincodeDefinitionForMyOrgProposal(LifecycleApproveChaincodeDefinitionForMyOrgRequest lifecycleApproveChaincodeDefinitionForMyOrgRequest, Peer peer) throws ProposalException, InvalidArgumentException Approve chaincode to be run on this peer's organization.- Parameters:
lifecycleApproveChaincodeDefinitionForMyOrgRequest
- the request seeLifecycleApproveChaincodeDefinitionForMyOrgRequest
peer
-- Returns:
- A
LifecycleApproveChaincodeDefinitionForMyOrgProposalResponse
- Throws:
ProposalException
InvalidArgumentException
-
sendLifecycleApproveChaincodeDefinitionForMyOrgProposal
public Collection<LifecycleApproveChaincodeDefinitionForMyOrgProposalResponse> sendLifecycleApproveChaincodeDefinitionForMyOrgProposal(LifecycleApproveChaincodeDefinitionForMyOrgRequest lifecycleApproveChaincodeDefinitionForMyOrgRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException Approve chaincode to be run on this peer's organization.- Parameters:
lifecycleApproveChaincodeDefinitionForMyOrgRequest
- the request seeLifecycleApproveChaincodeDefinitionForMyOrgRequest
peers
- to send the request to.- Returns:
- A
LifecycleApproveChaincodeDefinitionForMyOrgProposalResponse
- Throws:
ProposalException
InvalidArgumentException
-
sendLifecycleCommitChaincodeDefinitionProposal
public Collection<LifecycleCommitChaincodeDefinitionProposalResponse> sendLifecycleCommitChaincodeDefinitionProposal(LifecycleCommitChaincodeDefinitionRequest lifecycleCommitChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Commit chaincode final approval to run on all organizations that have approved.- Parameters:
lifecycleCommitChaincodeDefinitionRequest
- The request seeLifecycleCommitChaincodeDefinitionRequest
peers
- to send the request to.- Returns:
- A
LifecycleCommitChaincodeDefinitionProposalResponse
- Throws:
InvalidArgumentException
ProposalException
-
lifecycleQueryChaincodeDefinitions
public Collection<LifecycleQueryChaincodeDefinitionsProposalResponse> lifecycleQueryChaincodeDefinitions(LifecycleQueryChaincodeDefinitionsRequest proposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Query namespaces. Takes no specific arguments returns namespaces including chaincode names that have been committed.- Parameters:
proposalRequest
- the request.peers
- The peers to which the request will be sent.- Returns:
- Peer responses.
- Throws:
InvalidArgumentException
- if the channel is in an invalid state.ProposalException
-
sendLifecycleCheckCommitReadinessRequest
public Collection<LifecycleCheckCommitReadinessProposalResponse> sendLifecycleCheckCommitReadinessRequest(LifecycleCheckCommitReadinessRequest lifecycleCheckCommitReadinessRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Query approval status for all organizations.- Parameters:
lifecycleCheckCommitReadinessRequest
- The request seeLifecycleCheckCommitReadinessRequest
peers
- Peers to send the request. Usually only need one.- Returns:
- A
LifecycleCheckCommitReadinessProposalResponse
- Throws:
InvalidArgumentException
ProposalException
-
lifecycleQueryChaincodeDefinition
public Collection<LifecycleQueryChaincodeDefinitionProposalResponse> lifecycleQueryChaincodeDefinition(QueryLifecycleQueryChaincodeDefinitionRequest queryLifecycleQueryChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException lifecycleQueryChaincodeDefinition get definition of chaincode.- Parameters:
queryLifecycleQueryChaincodeDefinitionRequest
- The request seeQueryLifecycleQueryChaincodeDefinitionRequest
peers
- The peers to send the request to.- Returns:
- A
LifecycleQueryChaincodeDefinitionProposalResponse
- Throws:
InvalidArgumentException
ProposalException
-
queryInstantiatedChaincodes
public List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo> queryInstantiatedChaincodes(Peer peer) throws InvalidArgumentException, ProposalException Query peer for chaincode that has been instantiated This method may not be thread safe if client context is changed!- Parameters:
peer
- The peer to query.- Returns:
- A list of ChaincodeInfo @see
Query.ChaincodeInfo
- Throws:
InvalidArgumentException
ProposalException
-
queryInstantiatedChaincodes
public List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo> queryInstantiatedChaincodes(Peer peer, User userContext) throws InvalidArgumentException, ProposalException Query peer for chaincode that has been instantiated- Parameters:
peer
- The peer to query.userContext
- the user context.- Returns:
- A list of ChaincodeInfo @see
Query.ChaincodeInfo
- Throws:
InvalidArgumentException
ProposalException
-
queryCollectionsConfig
public CollectionConfigPackage queryCollectionsConfig(String chaincodeName, Peer peer, User userContext) throws InvalidArgumentException, ProposalException Get information on the collections used by the chaincode.- Parameters:
chaincodeName
- The name of the chaincode to query.peer
- Peer to query.userContext
- The context of the user to sign the request.- Returns:
- CollectionConfigPackage with information on the collection used by the chaincode.
- Throws:
InvalidArgumentException
ProposalException
-
sendTransactionProposal
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest) throws ProposalException, InvalidArgumentException Send a transaction proposal.- Parameters:
transactionProposalRequest
- The transaction proposal to be sent to all the required peers needed for endorsing.- Returns:
- responses from peers.
- Throws:
InvalidArgumentException
ProposalException
-
sendTransactionProposalToEndorsers
public Collection<ProposalResponse> sendTransactionProposalToEndorsers(TransactionProposalRequest transactionProposalRequest, Channel.DiscoveryOptions discoveryOptions) throws ProposalException, InvalidArgumentException, ServiceDiscoveryException Send a transaction proposal.- Parameters:
transactionProposalRequest
- The transaction proposal to be sent to all the required peers needed for endorsing.discoveryOptions
-- Returns:
- responses from peers.
- Throws:
InvalidArgumentException
ProposalException
ServiceDiscoveryException
-
getDiscoveredChaincodeNames
Collection of discovered chaincode names.- Returns:
-
sendTransactionProposal
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException Send a transaction proposal to specific peers.- Parameters:
transactionProposalRequest
- The transaction proposal to be sent to the peers.peers
-- Returns:
- responses from peers.
- Throws:
InvalidArgumentException
ProposalException
-
queryByChaincode
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest) throws InvalidArgumentException, ProposalException Send Query proposal- Parameters:
queryByChaincodeRequest
-- Returns:
- Collection proposal responses.
- Throws:
InvalidArgumentException
ProposalException
-
queryByChaincode
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException Send Query proposal- Parameters:
queryByChaincodeRequest
-peers
-- Returns:
- responses from peers.
- Throws:
InvalidArgumentException
ProposalException
-
setSDEndorserSelector
public ServiceDiscovery.EndorsementSelector setSDEndorserSelector(ServiceDiscovery.EndorsementSelector endorsementSelector) -
sendTransaction
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext) Send transaction to one of the orderers on the channel using a specific user context.- Parameters:
proposalResponses
- The proposal responses to be sent to the orderer.userContext
- The usercontext used for signing transaction.- Returns:
- a future allowing access to the result of the transaction invocation once complete.
-
sendTransaction
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses) Send transaction to one of the orderers on the channel using the usercontext set on the client.- Parameters:
proposalResponses
- .- Returns:
- a future allowing access to the result of the transaction invocation once complete.
-
sendTransaction
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers) Send transaction to one of the specified orderers using the usercontext set on the client..- Parameters:
proposalResponses
- The proposal responses to be sent to the ordererorderers
- The orderers to send the transaction to.- Returns:
- a future allowing access to the result of the transaction invocation once complete.
-
sendTransaction
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext) Send transaction to one of a specified set of orderers with the specified user context. IF there are no eventing peers this future returns immediately completed indicating that orderer has accepted the transaction only.- Parameters:
proposalResponses
-orderers
-- Returns:
- Future allowing access to the result of the transaction invocation.
-
sendTransaction
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses, Channel.TransactionOptions transactionOptions) Send transaction to one of a specified set of orderers with the specified user context. IF there are no eventing peers this future returns immediately completed indicating that orderer has accepted the transaction only.- Parameters:
proposalResponses
-transactionOptions
-- Returns:
- Future allowing access to the result of the transaction invocation.
-
registerBlockListener
Register a block listener.- Parameters:
listener
- function with single argument with typeBlockEvent
- Returns:
- The handle of the registered block listener.
- Throws:
InvalidArgumentException
- if the channel is shutdown.
-
registerBlockListener
public String registerBlockListener(BlockingQueue<QueuedBlockEvent> blockEventQueue) throws InvalidArgumentException Register a Queued block listener. This queue should never block insertion of events.- Parameters:
blockEventQueue
- the queue- Returns:
- return a handle to ungregister the handler.
- Throws:
InvalidArgumentException
-
registerBlockListener
public String registerBlockListener(BlockingQueue<QueuedBlockEvent> blockEventQueue, long timeout, TimeUnit timeUnit) throws InvalidArgumentException Register a Queued block listener. This queue should never block insertion of events.- Parameters:
blockEventQueue
- the queuetimeout
- The time that is waited on for event to be waited on the queuetimeUnit
- the time unit for timeout.- Returns:
- return a handle to ungregister the handler.
- Throws:
InvalidArgumentException
-
unregisterBlockListener
Unregister a block listener.- Parameters:
handle
- of Block listener to remove.- Returns:
- false if not found.
- Throws:
InvalidArgumentException
- if the channel is shutdown or invalid arguments.
-
getBlockListenerHandles
- Throws:
InvalidArgumentException
-
registerChaincodeEventListener
public String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener) throws InvalidArgumentException Register a chaincode event listener. Both chaincodeId pattern AND eventName pattern must match to invoke the chaincodeEventListener- Parameters:
chaincodeId
- Java pattern for chaincode identifier also know as chaincode name. If maeventName
- Java pattern to match the event name.chaincodeEventListener
- The listener to be invoked if both chaincodeId and eventName pattern matches.- Returns:
- Handle to be used to unregister the event listener
unregisterChaincodeEventListener(String)
- Throws:
InvalidArgumentException
-
unregisterChaincodeEventListener
Unregister an existing chaincode event listener.- Parameters:
handle
- Chaincode event listener handle to be unregistered.- Returns:
- True if the chaincode handler was found and removed.
- Throws:
InvalidArgumentException
-
shutdown
public void shutdown(boolean force) Shutdown the channel with all resources released.- Parameters:
force
- force immediate shutdown.
-
serializeChannel
Serialize channel to a file using Java serialization. Deserialized channel will NOT be in an initialized state.- Parameters:
file
- file- Throws:
IOException
InvalidArgumentException
-
serializeChannel
Serialize channel to a byte array using Java serialization. Deserialized channel will NOT be in an initialized state.- Throws:
InvalidArgumentException
IOException
-