-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPendingTransactionsStorage.cs
36 lines (29 loc) · 1.08 KB
/
PendingTransactionsStorage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Blockchain_Indexer.Blockchain.Transactions;
namespace Blockchain_Indexer.Services
{
public class PendingTransactionsStorage
{
private static readonly Dictionary<string, PendingTransaction> PendingTransactions = [];
public async Task AddPendingTransaction(PendingTransaction tx)
{
PendingTransactions.Add(tx.Hash, tx);
await Task.CompletedTask;
}
public async Task<PendingTransaction?> GetPendingTransactionAsync(string hash)
{
return await Task.FromResult(PendingTransactions.GetValueOrDefault(hash));
}
public async Task RemovePendingTransactionAsync(string hash)
{
PendingTransactions.Remove(hash);
await Task.CompletedTask;
}
public async Task<IEnumerable<PendingTransaction>> GetPendingTransactionsAsync(int pageIndex = 0)
{
var transactions = PendingTransactions.Values
.Skip(pageIndex * 15)
.Take(15);
return await Task.FromResult(transactions);
}
}
}