public List<ChaincodeMessage> Next()
 {
     List<StateMetadata> entriesList = new List<StateMetadata>();
     StateMetadata validationValue = new StateMetadata {Metakey = ChaincodeStub.VALIDATION_PARAMETER, Value = ByteString.CopyFrom(val)};
     entriesList.Add(validationValue);
     StateMetadataResult stateMetadataResult = new StateMetadataResult();
     stateMetadataResult.Entries.AddRange(entriesList);
     List<ChaincodeMessage> list = new List<ChaincodeMessage>();
     list.Add(new ChaincodeMessage {Type = ChaincodeMessage.Types.Type.Response, ChannelId = orgMsg.ChannelId, Txid = orgMsg.Txid, Payload = stateMetadataResult.ToByteString()});
     return list;
 }
Beispiel #2
0
        public virtual async Task <Dictionary <string, ByteString> > GetStateMetadataAsync(string channelId, string txId, string collection, string key, CancellationToken token = default(CancellationToken))
        {
            ByteString payload = await InvokeChaincodeSupportAsync(NewGetStateMetadataEventMessage(channelId, txId, collection, key), token).ConfigureAwait(false);

            try
            {
                StateMetadataResult             stateMetadataResult = StateMetadataResult.Parser.ParseFrom(payload);
                Dictionary <string, ByteString> stateMetadataMap    = new Dictionary <string, ByteString>();
                stateMetadataResult.Entries.ToList().ForEach(a => stateMetadataMap.Add(a.Metakey, a.Value));
                return(stateMetadataMap);
            }
            catch (InvalidProtocolBufferException e)
            {
                logger.Error($"[{txId},-8] unmarshall error");
                throw new Exception("Error unmarshalling StateMetadataResult.", e);
            }
        }