use of org.hyperledger.fabric.sdk.transaction.InstantiateProposalBuilder in project fabric-sdk-java by hyperledger.
the class Channel method sendInstantiationProposal.
/**
* Send instantiate request to the channel. Chaincode is created and initialized.
*
* @param instantiateProposalRequest
* @param peers
* @return responses from peers.
* @throws InvalidArgumentException
* @throws ProposalException
*/
public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
checkChannelState();
if (null == instantiateProposalRequest) {
throw new InvalidArgumentException("InstantiateProposalRequest is null");
}
instantiateProposalRequest.setSubmitted();
checkPeers(peers);
try {
TransactionContext transactionContext = getTransactionContext(instantiateProposalRequest.getUserContext());
transactionContext.setProposalWaitTime(instantiateProposalRequest.getProposalWaitTime());
InstantiateProposalBuilder instantiateProposalbuilder = InstantiateProposalBuilder.newBuilder();
instantiateProposalbuilder.context(transactionContext);
instantiateProposalbuilder.argss(instantiateProposalRequest.getArgs());
instantiateProposalbuilder.chaincodeName(instantiateProposalRequest.getChaincodeName());
instantiateProposalbuilder.chaincodeType(instantiateProposalRequest.getChaincodeLanguage());
instantiateProposalbuilder.chaincodePath(instantiateProposalRequest.getChaincodePath());
instantiateProposalbuilder.chaincodeVersion(instantiateProposalRequest.getChaincodeVersion());
instantiateProposalbuilder.chaincodEndorsementPolicy(instantiateProposalRequest.getChaincodeEndorsementPolicy());
instantiateProposalbuilder.setTransientMap(instantiateProposalRequest.getTransientMap());
FabricProposal.Proposal instantiateProposal = instantiateProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, instantiateProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
}
Aggregations