private synchronized void sendChannel(ChaincodeMessage message) { String key = getTxKey(message.getChannelId(), message.getTxid()); if (!responseChannel.containsKey(key)) { throw new IllegalStateException(format("[%-8.8s] sendChannel does not exist", message.getTxid())); } responseChannel.get(key).add(message); }
private ByteString invokeChaincodeSupport(final ChaincodeMessage message) { final String channelId = message.getChannelId(); final String txId = message.getTxid();
hash = (53 * hash) + getChannelId().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash;
markIsTransaction(message.getChannelId(), message.getTxid(), true); final ChaincodeStub stub = new ChaincodeStubImpl(message.getChannelId(), message.getTxid(), this, input.getArgsList(), message.getProposal()); queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), result.getMessage(), stub.getEvent())); } else { logger.fine(format(format("[%-8.8s] Init succeeded. Sending %s", message.getTxid(), COMPLETED))); queueOutboundChaincodeMessage(newCompletedEventMessage(message.getChannelId(), message.getTxid(), result, stub.getEvent())); queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), e)); } finally { deleteIsTransaction(message.getChannelId(), message.getTxid());
.equals(other.getChaincodeEvent()); result = result && getChannelId() .equals(other.getChannelId()); return result;
markIsTransaction(message.getChannelId(), message.getTxid(), true); final ChaincodeStub stub = new ChaincodeStubImpl(message.getChannelId(), message.getTxid(), this, input.getArgsList(), message.getProposal()); queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), result.getMessage(), stub.getEvent())); } else { logger.fine(format(format("[%-8.8s] Invoke succeeded. Sending %s", message.getTxid(), COMPLETED))); queueOutboundChaincodeMessage(newCompletedEventMessage(message.getChannelId(), message.getTxid(), result, stub.getEvent())); queueOutboundChaincodeMessage(newErrorEventMessage(message.getChannelId(), message.getTxid(), e)); } finally { deleteIsTransaction(message.getChannelId(), message.getTxid());
public Builder mergeFrom(org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage other) { if (other == org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.getDefaultInstance()) return this; if (other.type_ != 0) { setTypeValue(other.getTypeValue()); } if (other.hasTimestamp()) { mergeTimestamp(other.getTimestamp()); } if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { setPayload(other.getPayload()); } if (!other.getTxid().isEmpty()) { txid_ = other.txid_; onChanged(); } if (other.hasProposal()) { mergeProposal(other.getProposal()); } if (other.hasChaincodeEvent()) { mergeChaincodeEvent(other.getChaincodeEvent()); } if (!other.getChannelId().isEmpty()) { channelId_ = other.channelId_; onChanged(); } onChanged(); return this; }
/** * * @return Chaincode response packed as payload inside COMPLETE message packed as payload inside RESPONSE message */ @Override public List<ChaincodeShim.ChaincodeMessage> next() { ByteString chaincodeResponse = ProposalResponsePackage.Response.newBuilder() .setStatus(Chaincode.Response.Status.SUCCESS.getCode()) .setMessage("OK") .build().toByteString(); ByteString completePayload = ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.COMPLETED) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .setPayload(chaincodeResponse) .build().toByteString(); List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .setPayload(completePayload) .build()); return list; } }
/** * Generate response message that list of (key => value) pairs * @return */ @Override public List<ChaincodeShim.ChaincodeMessage> next() { List<KvQueryResult.KV> keyValues = Arrays.asList(values).stream(). map(x -> KvQueryResult.KV.newBuilder() .setKey(x) .setValue(ByteString.copyFromUtf8(x + " Value")) .build() ).collect(toList()); ChaincodeShim.QueryResponse.Builder builder = ChaincodeShim.QueryResponse.newBuilder(); builder.setHasMore(hasNext); keyValues.stream().forEach(kv -> builder.addResults(ChaincodeShim.QueryResultBytes.newBuilder().setResultBytes(kv.toByteString()))); ByteString rangePayload = builder.build().toByteString(); List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .setPayload(rangePayload) .build()); return list; } }
@Override public List<ChaincodeShim.ChaincodeMessage> next() { List<KvQueryResult.KeyModification> keyModifications = Arrays.asList(values).stream(). map(x -> KvQueryResult.KeyModification.newBuilder() .setTxId(x) .setValue(ByteString.copyFromUtf8(x + " Value")) .build() ).collect(toList()); ChaincodeShim.QueryResponse.Builder builder = ChaincodeShim.QueryResponse.newBuilder(); builder.setHasMore(hasNext); keyModifications.stream().forEach(kv -> builder.addResults(ChaincodeShim.QueryResultBytes.newBuilder().setResultBytes(kv.toByteString()))); ByteString historyPayload = builder.build().toByteString(); List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .setPayload(historyPayload) .build()); return list; } }
/** * * @return RESPONSE message with empty payload */ @Override public List<ChaincodeShim.ChaincodeMessage> next() { List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .build()); return list; } }
/** * <pre> *channel id * </pre> * * <code>optional string channel_id = 7;</code> */ public Builder clearChannelId() { channelId_ = getDefaultInstance().getChannelId(); onChanged(); return this; } /**
@Override public List<ChaincodeShim.ChaincodeMessage> next() { ByteString getPayload = ByteString.copyFromUtf8(val); List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .setPayload(getPayload) .build()); return list; } }
@Override public List<ChaincodeShim.ChaincodeMessage> next() { List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .build()); return list; } }
@Override public List<ChaincodeShim.ChaincodeMessage> next() { List<ChaincodeShim.ChaincodeMessage> list = new ArrayList<>(); list.add(ChaincodeShim.ChaincodeMessage.newBuilder() .setType(ChaincodeShim.ChaincodeMessage.Type.RESPONSE) .setChannelId(orgMsg.getChannelId()) .setTxid(orgMsg.getTxid()) .build()); return list; } }