mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-05 15:14:21 +01:00
BTCPayWallet should be singleton per cryptcode
This commit is contained in:
@@ -102,6 +102,7 @@ namespace BTCPayServer.Services.Wallets
|
||||
public void InvalidateCache(DerivationStrategyBase strategy)
|
||||
{
|
||||
_MemoryCache.Remove("CACHEDCOINS_" + strategy.ToString());
|
||||
_FetchingUTXOs.TryRemove(strategy.ToString(), out var unused);
|
||||
}
|
||||
ConcurrentDictionary<string, TaskCompletionSource<UTXOChanges>> _FetchingUTXOs = new ConcurrentDictionary<string, TaskCompletionSource<UTXOChanges>>();
|
||||
|
||||
|
||||
@@ -21,8 +21,15 @@ namespace BTCPayServer.Services.Wallets
|
||||
_Client = client;
|
||||
_NetworkProvider = networkProvider;
|
||||
_Options = memoryCacheOption;
|
||||
|
||||
foreach(var network in networkProvider.GetAll())
|
||||
{
|
||||
_Wallets.Add(network.CryptoCode, new BTCPayWallet(_Client.GetExplorerClient(network.CryptoCode), new MemoryCache(_Options), network));
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, BTCPayWallet> _Wallets = new Dictionary<string, BTCPayWallet>();
|
||||
|
||||
public BTCPayWallet GetWallet(BTCPayNetwork network)
|
||||
{
|
||||
if (network == null)
|
||||
@@ -33,11 +40,8 @@ namespace BTCPayServer.Services.Wallets
|
||||
{
|
||||
if (cryptoCode == null)
|
||||
throw new ArgumentNullException(nameof(cryptoCode));
|
||||
var network = _NetworkProvider.GetNetwork(cryptoCode);
|
||||
var client = _Client.GetExplorerClient(cryptoCode);
|
||||
if (network == null || client == null)
|
||||
return null;
|
||||
return new BTCPayWallet(client, new MemoryCache(_Options), network);
|
||||
_Wallets.TryGetValue(cryptoCode, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool IsAvailable(BTCPayNetwork network)
|
||||
|
||||
Reference in New Issue
Block a user