use of org.hyperledger.fabric.protos.peer.FabricProposal.ChaincodeProposalPayload in project fabric-sdk-java by hyperledger.
the class ProposalBuilder method createFabricProposal.
private FabricProposal.Proposal createFabricProposal(String channelID, Chaincode.ChaincodeID chaincodeID) {
if (null == transientMap) {
transientMap = Collections.emptyMap();
}
if (IS_DEBUG_LEVEL) {
for (Entry<String, byte[]> tme : transientMap.entrySet()) {
logger.debug(format("transientMap('%s', '%s'))", logString(tme.getKey()), logString(new String(tme.getValue(), UTF_8))));
}
}
ChaincodeHeaderExtension chaincodeHeaderExtension = ChaincodeHeaderExtension.newBuilder().setChaincodeId(chaincodeID).build();
Common.ChannelHeader chainHeader = createChannelHeader(HeaderType.ENDORSER_TRANSACTION, context.getTxID(), channelID, context.getEpoch(), context.getFabricTimestamp(), chaincodeHeaderExtension, null);
ChaincodeInvocationSpec chaincodeInvocationSpec = createChaincodeInvocationSpec(chaincodeID, ccType);
// Convert to bytestring map.
Map<String, ByteString> bsm = new HashMap<>(transientMap.size());
for (Entry<String, byte[]> tme : transientMap.entrySet()) {
bsm.put(tme.getKey(), ByteString.copyFrom(tme.getValue()));
}
ChaincodeProposalPayload payload = ChaincodeProposalPayload.newBuilder().setInput(chaincodeInvocationSpec.toByteString()).putAllTransientMap(bsm).build();
Common.Header header = Common.Header.newBuilder().setSignatureHeader(getSignatureHeaderAsByteString(context)).setChannelHeader(chainHeader.toByteString()).build();
return FabricProposal.Proposal.newBuilder().setHeader(header.toByteString()).setPayload(payload.toByteString()).build();
}
Aggregations