Пример #1
0
 internal static ReadOnlyCollection <TokenTransfer> Create(RepeatedField <Proto.TokenTransferList> list)
 {
     if (list != null && list.Count > 0)
     {
         var collector = new Dictionary <(Address, Address), long>();
         foreach (var xferList in list)
         {
             var token = xferList.Token.AsAddress();
             foreach (var xfer in xferList.Transfers)
             {
                 var key = (token, xfer.AccountID.AsAddress());
                 collector.TryGetValue(key, out long amount);
                 collector[key] = amount + xfer.Amount;
             }
         }
         var result = new List <TokenTransfer>(collector.Count);
         foreach (var entry in collector)
         {
             result.Add(new TokenTransfer(entry.Key.Item1, entry.Key.Item2, entry.Value));
         }
         return(result.AsReadOnly());
     }
     return(EMPTY_RESULT);
 }