use of org.hyperledger.fabric.sdk.transaction.ProposalBuilder in project fabric-sdk-java by hyperledger.
the class Channel method sendProposal.
private Collection<ProposalResponse> sendProposal(TransactionRequest proposalRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
checkChannelState();
checkPeers(peers);
if (null == proposalRequest) {
throw new InvalidArgumentException("The proposalRequest is null");
}
if (Utils.isNullOrEmpty(proposalRequest.getFcn())) {
throw new InvalidArgumentException("The proposalRequest's fcn is null or empty.");
}
if (proposalRequest.getChaincodeID() == null) {
throw new InvalidArgumentException("The proposalRequest's chaincode ID is null");
}
proposalRequest.setSubmitted();
try {
TransactionContext transactionContext = getTransactionContext(proposalRequest.getUserContext());
transactionContext.verify(proposalRequest.doVerify());
transactionContext.setProposalWaitTime(proposalRequest.getProposalWaitTime());
// Protobuf message builder
ProposalBuilder proposalBuilder = ProposalBuilder.newBuilder();
proposalBuilder.context(transactionContext);
proposalBuilder.request(proposalRequest);
SignedProposal invokeProposal = getSignedProposal(transactionContext, proposalBuilder.build());
return sendProposalToPeers(peers, invokeProposal, transactionContext);
} catch (ProposalException e) {
throw e;
} catch (Exception e) {
ProposalException exp = new ProposalException(e);
logger.error(exp.getMessage(), exp);
throw exp;
}
}
Aggregations