예제 #1
0
        private Proposal CreateFabricProposal(string chID, Protos.Peer.ChaincodeID ccodeID)
        {
            if (null == transientMap)
            {
                transientMap = new Dictionary <string, byte[]>();
            }

            if (IS_DEBUG_LEVEL)
            {
                foreach (KeyValuePair <string, byte[]> tme in transientMap)
                {
                    logger.Debug($"transientMap('{tme.Key.LogString()}', '{Encoding.UTF8.GetString(tme.Value).LogString()}'))");
                }
            }

            ChaincodeHeaderExtension chaincodeHeaderExtension = new ChaincodeHeaderExtension {
                ChaincodeId = ccodeID
            };

            ChannelHeader chainHeader = ProtoUtils.CreateChannelHeader(HeaderType.EndorserTransaction, context.TxID, chID, context.Epoch, context.FabricTimestamp, chaincodeHeaderExtension, null);

            ChaincodeInvocationSpec chaincodeInvocationSpec = CreateChaincodeInvocationSpec(ccodeID, ccType);

            ChaincodeProposalPayload payload = new ChaincodeProposalPayload {
                Input = chaincodeInvocationSpec.ToByteString()
            };

            foreach (KeyValuePair <string, byte[]> pair in transientMap)
            {
                payload.TransientMap.Add(pair.Key, ByteString.CopyFrom(pair.Value));
            }
            Header header = new Header {
                SignatureHeader = ProtoUtils.GetSignatureHeaderAsByteString(context), ChannelHeader = chainHeader.ToByteString()
            };

            return(new Proposal {
                Header = header.ToByteString(), Payload = payload.ToByteString()
            });
        }