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);
}
}
Aggregations