public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
/** * <pre> * Optional extensions to the proposal. Its content depends on the Header's * type field. For the type CHAINCODE, it might be the bytes of a * ChaincodeAction message. * </pre> * * <code>optional bytes extension = 3;</code> */ public Builder setExtension(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } extension_ = value; onChanged(); return this; } /**
@Test public void testGetTransient() { final SignedProposal signedProposal = SignedProposal.newBuilder() .setProposalBytes(Proposal.newBuilder() .setHeader(Header.newBuilder() .setChannelHeader(ChannelHeader.newBuilder() .setType(ENDORSER_TRANSACTION_VALUE) .setTimestamp(Timestamp.getDefaultInstance()) .build().toByteString() ) .build().toByteString() ) .setPayload(ChaincodeProposalPayload.newBuilder() .putTransientMap("key0", ByteString.copyFromUtf8("value0")) .putTransientMap("key1", ByteString.copyFromUtf8("value1")) .build().toByteString() ) .build().toByteString() ).build(); final ChaincodeStubImpl stub = new ChaincodeStubImpl("myc", "txid", handler, new ArrayList<>(), signedProposal); assertThat(stub.getTransient(), allOf( hasEntry("key0", "value0".getBytes(UTF_8)), hasEntry("key1", "value1".getBytes(UTF_8)) )); }
@Test public void testGetCreator() { final Instant instant = Instant.now(); final byte[] creator = "CREATOR".getBytes(UTF_8); final Timestamp timestamp = Timestamp.newBuilder().setSeconds(instant.getEpochSecond()).setNanos(instant.getNano()).build(); final SignedProposal signedProposal = SignedProposal.newBuilder() .setProposalBytes(Proposal.newBuilder() .setHeader(Header.newBuilder() .setChannelHeader(ChannelHeader.newBuilder() .setType(ENDORSER_TRANSACTION_VALUE) .setTimestamp(timestamp) .build().toByteString() ) .setSignatureHeader(SignatureHeader.newBuilder() .setCreator(ByteString.copyFrom(creator)) .build().toByteString() ) .build().toByteString() ) .build().toByteString() ).build(); final ChaincodeStubImpl stub = new ChaincodeStubImpl("myc", "txid", handler, new ArrayList<>(), signedProposal); assertThat(stub.getCreator(), is(creator)); }
@Test public void testGetBinding() { final byte[] expectedDigest = DatatypeConverter.parseHexBinary("5093dd4f4277e964da8f4afbde0a9674d17f2a6a5961f0670fc21ae9b67f2983"); final SignedProposal signedProposal = SignedProposal.newBuilder() .setProposalBytes(Proposal.newBuilder() .setHeader(Header.newBuilder() .setChannelHeader(ChannelHeader.newBuilder() .setType(ENDORSER_TRANSACTION_VALUE) .setTimestamp(Timestamp.getDefaultInstance()) .setEpoch(10) .build().toByteString() ) .setSignatureHeader(SignatureHeader.newBuilder() .setNonce(ByteString.copyFromUtf8("nonce")) .setCreator(ByteString.copyFromUtf8("creator")) .build().toByteString() ) .build().toByteString() ) .build().toByteString() ).build(); final ChaincodeStubImpl stub = new ChaincodeStubImpl("myc", "txid", handler, new ArrayList<>(), signedProposal); assertThat(stub.getBinding(), is(expectedDigest)); }
@Test public void testGetTxTimestamp() { final Instant instant = Instant.now(); final Timestamp timestamp = Timestamp.newBuilder().setSeconds(instant.getEpochSecond()).setNanos(instant.getNano()).build(); final SignedProposal signedProposal = SignedProposal.newBuilder() .setProposalBytes(Proposal.newBuilder() .setHeader(Header.newBuilder() .setChannelHeader(ChannelHeader.newBuilder() .setType(ENDORSER_TRANSACTION_VALUE) .setTimestamp(timestamp) .build().toByteString() ) .build().toByteString() ) .build().toByteString() ).build(); final ChaincodeStubImpl stub = new ChaincodeStubImpl("myc", "txid", handler, new ArrayList<>(), signedProposal); assertThat(stub.getTxTimestamp(), is(instant)); }
/** * <pre> * The payload of the proposal as defined by the type in the proposal * header. * </pre> * * <code>optional bytes payload = 2;</code> */ public Builder setPayload(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } payload_ = value; onChanged(); return this; } /**
@Test public void testGetSignedProposal() { final SignedProposal signedProposal = SignedProposal.newBuilder() .setProposalBytes(Proposal.newBuilder() .setHeader(Header.newBuilder() .setChannelHeader(ChannelHeader.newBuilder() .setType(ENDORSER_TRANSACTION_VALUE) .setTimestamp(Timestamp.getDefaultInstance()) .build().toByteString() ) .build().toByteString() ) .build().toByteString() ).build(); final ChaincodeStubImpl stub = new ChaincodeStubImpl("myc", "txId", handler, Collections.emptyList(), signedProposal); assertThat(stub.getSignedProposal(), is(signedProposal)); }
/** * <pre> * The header of the proposal. It is the bytes of the Header * </pre> * * <code>optional bytes header = 1;</code> */ public Builder setHeader(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } header_ = value; onChanged(); return this; } /**
/** * <pre> * Optional extensions to the proposal. Its content depends on the Header's * type field. For the type CHAINCODE, it might be the bytes of a * ChaincodeAction message. * </pre> * * <code>optional bytes extension = 3;</code> */ public Builder clearExtension() { extension_ = getDefaultInstance().getExtension(); onChanged(); return this; } public final Builder setUnknownFields(
private Builder() { maybeForceBuilderInitialization(); }
public Builder mergeFrom(org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal other) { if (other == org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal.getDefaultInstance()) return this; if (other.getHeader() != com.google.protobuf.ByteString.EMPTY) { setHeader(other.getHeader()); } if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) { setPayload(other.getPayload()); } if (other.getExtension() != com.google.protobuf.ByteString.EMPTY) { setExtension(other.getExtension()); } onChanged(); return this; }
/** * <pre> * The payload of the proposal as defined by the type in the proposal * header. * </pre> * * <code>optional bytes payload = 2;</code> */ public Builder clearPayload() { payload_ = getDefaultInstance().getPayload(); onChanged(); return this; }
public static Builder newBuilder(org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() {
public org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal buildPartial() { org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal result = new org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal(this); result.header_ = header_; result.payload_ = payload_; result.extension_ = extension_; onBuilt(); return result; }
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal) { return mergeFrom((org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal)other); } else { super.mergeFrom(other); return this; } }
/** * <pre> * The header of the proposal. It is the bytes of the Header * </pre> * * <code>optional bytes header = 1;</code> */ public Builder clearHeader() { header_ = getDefaultInstance().getHeader(); onChanged(); return this; }
public org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal build() { org.hyperledger.fabric.protos.peer.ProposalPackage.Proposal result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }