public class Channel extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Channel.PeerOptions
Options for the peer.
|
Modifier and Type | Method and Description |
---|---|
Channel |
addEventHub(EventHub eventHub)
Add an Event Hub to this channel.
|
Channel |
addOrderer(Orderer orderer)
Add an Orderer to this channel.
|
Channel |
addPeer(Peer peer)
Add a peer to the channel
|
Channel |
addPeer(Peer peer,
Channel.PeerOptions peerOptions)
Add a peer to the channel
|
byte[] |
getChannelConfigurationBytes()
Channel Configuration bytes.
|
Collection<EventHub> |
getEventHubs()
Get all Event Hubs on this channel.
|
String |
getName()
Get the channel name
|
Collection<Orderer> |
getOrderers() |
Collection<Peer> |
getPeers()
Get the peers for this channel.
|
Collection<Peer> |
getPeers(EnumSet<Peer.PeerRole> roles)
Get the peers for this channel.
|
Channel.PeerOptions |
getPeersOptions(Peer peer) |
byte[] |
getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration,
User signer)
Get signed byes of the update channel.
|
Channel |
initialize()
Initialize the Channel.
|
boolean |
isInitialized()
Is channel initialized.
|
boolean |
isShutdown()
Is the channel shutdown.
|
Channel |
joinPeer(Peer peer)
Join the peer to the channel.
|
Channel |
joinPeer(Peer peer,
Channel.PeerOptions peerOptions) |
BlockInfo |
queryBlockByHash(byte[] blockHash)
query this channel for a Block by the block hash.
|
BlockInfo |
queryBlockByHash(Peer peer,
byte[] blockHash)
Query a peer in this channel for a Block by the block hash.
|
BlockInfo |
queryBlockByNumber(long blockNumber)
query this channel for a Block by the blockNumber.
|
BlockInfo |
queryBlockByNumber(Peer peer,
long blockNumber)
query a peer in this channel for a Block by the blockNumber
|
BlockInfo |
queryBlockByTransactionID(Peer peer,
String txID)
query a peer in this channel for a Block by a TransactionID contained in the block
|
BlockInfo |
queryBlockByTransactionID(String txID)
query this channel for a Block by a TransactionID contained in the block
The request is sent to a random peer in the channel
|
BlockchainInfo |
queryBlockchainInfo()
query this channel for chain information.
|
BlockchainInfo |
queryBlockchainInfo(Peer peer)
query for chain information
|
Collection<ProposalResponse> |
queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest)
Send Query proposal
|
Collection<ProposalResponse> |
queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest,
Collection<Peer> peers)
Send Query proposal
|
List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo> |
queryInstantiatedChaincodes(Peer peer)
Query peer for chaincode that has been instantiated
|
TransactionInfo |
queryTransactionByID(Peer peer,
String txID)
Query for a Fabric Transaction given its transactionID
|
TransactionInfo |
queryTransactionByID(String txID)
Query this channel for a Fabric Transaction given its transactionID.
|
String |
registerBlockListener(BlockListener listener)
Register a block listener.
|
String |
registerChaincodeEventListener(Pattern chaincodeId,
Pattern eventName,
ChaincodeEventListener chaincodeEventListener)
Register a chaincode event listener.
|
void |
removePeer(Peer peer)
Removes the peer connection from the channel.
|
Collection<ProposalResponse> |
sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest)
Send instantiate request to the channel.
|
Collection<ProposalResponse> |
sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
Collection<Peer> peers)
Send instantiate request to the channel.
|
CompletableFuture<BlockEvent.TransactionEvent> |
sendTransaction(Collection<ProposalResponse> proposalResponses)
Send transaction to one of the orderers on the channel using the usercontext set on the client.
|
CompletableFuture<BlockEvent.TransactionEvent> |
sendTransaction(Collection<ProposalResponse> proposalResponses,
Collection<Orderer> orderers)
Send transaction to one of the specified orderers using the usercontext set on the client..
|
CompletableFuture<BlockEvent.TransactionEvent> |
sendTransaction(Collection<ProposalResponse> proposalResponses,
Collection<Orderer> orderers,
User userContext)
Send transaction to one of a specified set of orderers with the specified user context.
|
CompletableFuture<BlockEvent.TransactionEvent> |
sendTransaction(Collection<ProposalResponse> proposalResponses,
User userContext)
Send transaction to one of the orderers on the channel using a specific user context.
|
Collection<ProposalResponse> |
sendTransactionProposal(TransactionProposalRequest transactionProposalRequest)
Send a transaction proposal.
|
Collection<ProposalResponse> |
sendTransactionProposal(TransactionProposalRequest transactionProposalRequest,
Collection<Peer> peers)
Send a transaction proposal to specific peers.
|
Collection<ProposalResponse> |
sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest)
Send Upgrade proposal proposal to upgrade chaincode to a new version.
|
Collection<ProposalResponse> |
sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest,
Collection<Peer> peers)
Send Upgrade proposal proposal to upgrade chaincode to a new version.
|
byte[] |
serializeChannel()
Serialize channel to a byte array using Java serialization.
|
void |
serializeChannel(File file)
Serialize channel to a file using Java serialization.
|
void |
shutdown(boolean force)
Shutdown the channel with all resources released.
|
boolean |
unregisterBlockListener(String handle)
Unregister a block listener.
|
boolean |
unregisterChaincodeEventListener(String handle)
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 configuration
|
public Collection<EventHub> getEventHubs()
public void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers) throws TransactionException, InvalidArgumentException
updateChannelConfiguration
- Updated Channel configurationsigners
- signersTransactionException
InvalidArgumentException
public void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers) throws TransactionException, InvalidArgumentException
updateChannelConfiguration
- Channel configurationsigners
- signersorderer
- The specific orderer to use.TransactionException
InvalidArgumentException
public boolean isInitialized()
public String getName()
public Channel addPeer(Peer peer) throws InvalidArgumentException
peer
- The Peer to add.InvalidArgumentException
public Channel addPeer(Peer peer, Channel.PeerOptions peerOptions) throws InvalidArgumentException
peer
- The Peer to add.peerOptions
- see Peer.PeerRole
InvalidArgumentException
public Channel joinPeer(Peer peer) throws ProposalException
Channel.PeerOptions
peer
- the peer to join the channel.ProposalException
public Channel joinPeer(Peer peer, Channel.PeerOptions peerOptions) throws ProposalException
peer
- the peer to join the channel.peerOptions
- see Channel.PeerOptions
ProposalException
public void removePeer(Peer peer) throws InvalidArgumentException
peer
- InvalidArgumentException
public Channel addOrderer(Orderer orderer) throws InvalidArgumentException
orderer
- the orderer to add.InvalidArgumentException
public Channel.PeerOptions getPeersOptions(Peer peer)
public Channel addEventHub(EventHub eventHub) throws InvalidArgumentException
eventHub
- InvalidArgumentException
public Collection<Peer> getPeers()
public Collection<Peer> getPeers(EnumSet<Peer.PeerRole> roles)
public Channel initialize() throws InvalidArgumentException, TransactionException
InvalidArgumentException
TransactionException
public boolean isShutdown()
public byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer) throws InvalidArgumentException
updateChannelConfiguration
- signer
- InvalidArgumentException
public byte[] getChannelConfigurationBytes() throws TransactionException
<p>
curl -v POST --data-binary @fooConfig http://host/protolator/decode/common.Config
<p>
See http://hyperledger-fabric.readthedocs.io/en/latest/configtxlator.htmlTransactionException
public Collection<Orderer> getOrderers()
public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest) throws InvalidArgumentException, ProposalException
instantiateProposalRequest
- send instantiate chaincode proposal request.InvalidArgumentException
ProposalException
public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException
instantiateProposalRequest
- peers
- InvalidArgumentException
ProposalException
public Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest) throws ProposalException, InvalidArgumentException
upgradeProposalRequest
- ProposalException
InvalidArgumentException
public Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException
upgradeProposalRequest
- peers
- the specific peers to send to.ProposalException
InvalidArgumentException
public BlockInfo queryBlockByHash(byte[] blockHash) throws InvalidArgumentException, ProposalException
blockHash
- the hash of the Block in the chainBlockInfo
with the given block HashInvalidArgumentException
ProposalException
public BlockInfo queryBlockByHash(Peer peer, byte[] blockHash) throws InvalidArgumentException, ProposalException
peer
- the Peer to query.blockHash
- the hash of the Block in the chain.BlockInfo
with the given block HashInvalidArgumentException
- if the channel is shutdown or any of the arguments are not valid.ProposalException
- if an error occurred processing the query.public BlockInfo queryBlockByNumber(long blockNumber) throws InvalidArgumentException, ProposalException
blockNumber
- index of the Block in the chainBlockInfo
with the given blockNumberInvalidArgumentException
ProposalException
public BlockInfo queryBlockByNumber(Peer peer, long blockNumber) throws InvalidArgumentException, ProposalException
peer
- the peer to send the request toblockNumber
- index of the Block in the chainBlockInfo
with the given blockNumberInvalidArgumentException
ProposalException
public BlockInfo queryBlockByTransactionID(String txID) throws InvalidArgumentException, ProposalException
txID
- the transactionID to query onBlockInfo
for the Block containing the transactionInvalidArgumentException
ProposalException
public BlockInfo queryBlockByTransactionID(Peer peer, String txID) throws InvalidArgumentException, ProposalException
peer
- the peer to send the request totxID
- the transactionID to query onBlockInfo
for the Block containing the transactionInvalidArgumentException
ProposalException
public BlockchainInfo queryBlockchainInfo() throws ProposalException, InvalidArgumentException
BlockchainInfo
object containing the chain info requestedInvalidArgumentException
ProposalException
public BlockchainInfo queryBlockchainInfo(Peer peer) throws ProposalException, InvalidArgumentException
peer
- The peer to send the request toBlockchainInfo
object containing the chain info requestedInvalidArgumentException
ProposalException
public TransactionInfo queryTransactionByID(String txID) throws ProposalException, InvalidArgumentException
txID
- the ID of the transactionTransactionInfo
ProposalException
InvalidArgumentException
public TransactionInfo queryTransactionByID(Peer peer, String txID) throws ProposalException, InvalidArgumentException
txID
- the ID of the transactionpeer
- the peer to send the request toTransactionInfo
ProposalException
InvalidArgumentException
public List<org.hyperledger.fabric.protos.peer.Query.ChaincodeInfo> queryInstantiatedChaincodes(Peer peer) throws InvalidArgumentException, ProposalException
peer
- The peer to query.Query.ChaincodeInfo
InvalidArgumentException
ProposalException
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest) throws ProposalException, InvalidArgumentException
transactionProposalRequest
- The transaction proposal to be sent to all the peers.InvalidArgumentException
ProposalException
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException
transactionProposalRequest
- The transaction proposal to be sent to the peers.peers
- InvalidArgumentException
ProposalException
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest) throws InvalidArgumentException, ProposalException
queryByChaincodeRequest
- InvalidArgumentException
ProposalException
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException
queryByChaincodeRequest
- peers
- InvalidArgumentException
ProposalException
public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext)
proposalResponses
- The proposal responses to be sent to the orderer.userContext
- The usercontext used for signing transaction.public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses)
proposalResponses
- .public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers)
proposalResponses
- The proposal responses to be sent to the ordererorderers
- The orderers to send the transaction to.public CompletableFuture<BlockEvent.TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext)
proposalResponses
- orderers
- public String registerBlockListener(BlockListener listener) throws InvalidArgumentException
listener
- function with single argument with type BlockEvent
InvalidArgumentException
- if the channel is shutdown.public boolean unregisterBlockListener(String handle) throws InvalidArgumentException
handle
- of Block listener to remove.InvalidArgumentException
- if the channel is shutdown or invalid arguments.public String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener) throws InvalidArgumentException
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.unregisterChaincodeEventListener(String)
InvalidArgumentException
public boolean unregisterChaincodeEventListener(String handle) throws InvalidArgumentException
handle
- Chaincode event listener handle to be unregistered.InvalidArgumentException
public void shutdown(boolean force)
force
- force immediate shutdown.public void serializeChannel(File file) throws IOException, InvalidArgumentException
file
- fileIOException
InvalidArgumentException
public byte[] serializeChannel() throws IOException, InvalidArgumentException
InvalidArgumentException
IOException
Copyright © 2018. All rights reserved.