Search in sources :

Example 1 with UpgradeProposalBuilder

use of org.hyperledger.fabric.sdk.transaction.UpgradeProposalBuilder in project fabric-sdk-java by hyperledger.

the class Channel method sendUpgradeProposal.

/**
 * Send Upgrade proposal proposal to upgrade chaincode to a new version.
 *
 * @param upgradeProposalRequest
 * @param peers                  the specific peers to send to.
 * @return Collection of proposal responses.
 * @throws ProposalException
 * @throws InvalidArgumentException
 */
public Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
    checkChannelState();
    checkPeers(peers);
    if (null == upgradeProposalRequest) {
        throw new InvalidArgumentException("Upgradeproposal is null");
    }
    try {
        TransactionContext transactionContext = getTransactionContext(upgradeProposalRequest.getUserContext());
        // transactionContext.verify(false);  // Install will have no signing cause it's not really targeted to a channel.
        transactionContext.setProposalWaitTime(upgradeProposalRequest.getProposalWaitTime());
        UpgradeProposalBuilder upgradeProposalBuilder = UpgradeProposalBuilder.newBuilder();
        upgradeProposalBuilder.context(transactionContext);
        upgradeProposalBuilder.argss(upgradeProposalRequest.getArgs());
        upgradeProposalBuilder.chaincodeName(upgradeProposalRequest.getChaincodeName());
        upgradeProposalBuilder.chaincodePath(upgradeProposalRequest.getChaincodePath());
        upgradeProposalBuilder.chaincodeVersion(upgradeProposalRequest.getChaincodeVersion());
        upgradeProposalBuilder.chaincodEndorsementPolicy(upgradeProposalRequest.getChaincodeEndorsementPolicy());
        SignedProposal signedProposal = getSignedProposal(transactionContext, upgradeProposalBuilder.build());
        return sendProposalToPeers(peers, signedProposal, transactionContext);
    } catch (Exception e) {
        throw new ProposalException(e);
    }
}
Also used : InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) TransactionContext(org.hyperledger.fabric.sdk.transaction.TransactionContext) UpgradeProposalBuilder(org.hyperledger.fabric.sdk.transaction.UpgradeProposalBuilder) SignedProposal(org.hyperledger.fabric.protos.peer.FabricProposal.SignedProposal) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException) EventHubException(org.hyperledger.fabric.sdk.exception.EventHubException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) TransactionException(org.hyperledger.fabric.sdk.exception.TransactionException) TransactionEventException(org.hyperledger.fabric.sdk.exception.TransactionEventException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) StatusRuntimeException(io.grpc.StatusRuntimeException) CryptoException(org.hyperledger.fabric.sdk.exception.CryptoException) TimeoutException(java.util.concurrent.TimeoutException) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 SignedProposal (org.hyperledger.fabric.protos.peer.FabricProposal.SignedProposal)1 CryptoException (org.hyperledger.fabric.sdk.exception.CryptoException)1 EventHubException (org.hyperledger.fabric.sdk.exception.EventHubException)1 InvalidArgumentException (org.hyperledger.fabric.sdk.exception.InvalidArgumentException)1 ProposalException (org.hyperledger.fabric.sdk.exception.ProposalException)1 TransactionEventException (org.hyperledger.fabric.sdk.exception.TransactionEventException)1 TransactionException (org.hyperledger.fabric.sdk.exception.TransactionException)1 TransactionContext (org.hyperledger.fabric.sdk.transaction.TransactionContext)1 UpgradeProposalBuilder (org.hyperledger.fabric.sdk.transaction.UpgradeProposalBuilder)1