Line data Source code
1 : import 'package:walletkit_dart/walletkit_dart.dart';
2 :
3 24 : final Map<CoinEntity, UtxoInMemoryCache> _utxoCaches = {};
4 :
5 8 : UtxoInMemoryCache getUtxoInMemoryCache(CoinEntity coin) {
6 16 : if (_utxoCaches[coin] == null) {
7 24 : _utxoCaches[coin] = UtxoInMemoryCache();
8 : }
9 16 : return _utxoCaches[coin]!;
10 : }
11 :
12 : class UtxoInMemoryCache {
13 : final Map<String, UTXOTransaction> _txCache = {};
14 :
15 8 : UTXOTransaction? getTx({required String txHash}) {
16 24 : return _txCache[txHash.toLowerCase()];
17 : }
18 :
19 8 : void insertTxIfConfirmed(UTXOTransaction tx) {
20 8 : if (tx.isPending) {
21 : return;
22 : }
23 16 : if (tx.confirmations <= 0) {
24 : return;
25 : }
26 32 : _txCache[tx.hash.toLowerCase()] = tx;
27 : }
28 : }
|