public async Task <bool> DeleteHistoryAddressIfExistsAsync(string address, HistoryAddressCategory category)
        {
            var partitionKey = GetHistoryPartitionKey(address);
            var rowKey       = GetHistoryRowKey(category);

            return(await _historyAddressesStorage.DeleteIfExistAsync(partitionKey, rowKey));
        }
 public async Task <bool> IsHistoryAddressExistsAsync(string address, HistoryAddressCategory category)
 {
     return(await _historyAddressesStorage.RecordExistsAsync(new HistoryAddressEntity()
     {
         PartitionKey = GetHistoryPartitionKey(address),
         RowKey = GetHistoryRowKey(category)
     }));
 }
Esempio n. 3
0
        public async Task UpsertAsync(HistoryAddressCategory category, string affectedAddress, DateTime timestampUtc, string hash,
                                      Guid?operationId, string fromAddress, string toAddress, decimal amount, string assetId)
        {
            await _historyStorage.InsertOrReplaceAsync(new HistoryItemEntity
            {
                PartitionKey = GetHistoryPartitionKey(category, affectedAddress),
                RowKey       = GetHistoryRowKey(timestampUtc, hash),
                TimestampUtc = timestampUtc,
                Hash         = hash,
                OperationId  = operationId,
                FromAddress  = fromAddress,
                ToAddress    = toAddress,
                Amount       = amount,
                AssetId      = assetId
            });

            await _indexStorage.InsertOrReplaceAsync(new IndexEntity
            {
                PartitionKey = GetIndexPartitionKey(hash),
                RowKey       = GetIndexRowKey(),
                TimestampUtc = timestampUtc
            });
        }
Esempio n. 4
0
        public async Task <IEnumerable <IHistoryItem> > GetByAddressAsync(HistoryAddressCategory category, string address, string afterHash = null, int take = 100)
        {
            var partitionKey = GetHistoryPartitionKey(category, address);

            if (!string.IsNullOrWhiteSpace(afterHash))
            {
                var index = await _indexStorage.GetDataAsync(GetIndexPartitionKey(afterHash), GetIndexRowKey());

                if (index != null)
                {
                    var rowKey = GetHistoryRowKey(index.TimestampUtc, afterHash);
                    var page   = new PagingInfo {
                        ElementCount = take
                    };
                    var query = new TableQuery <HistoryItemEntity>()
                                .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey))
                                .Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThan, rowKey));

                    return(await _historyStorage.ExecuteQueryWithPaginationAsync(query, page));
                }
            }

            return(await _historyStorage.GetTopRecordsAsync(partitionKey, take));
        }
Esempio n. 5
0
 private static string GetHistoryPartitionKey(HistoryAddressCategory category, string address) => $"{Enum.GetName(typeof(HistoryAddressCategory), category)}_{address}";
 private static string GetHistoryRowKey(HistoryAddressCategory category) => Enum.GetName(typeof(HistoryAddressCategory), category);