Add lock around CTS access
MODIFY
WalletWasabi/BitcoinCore/CachedRpcClient.cs
WalletWasabi/BitcoinCore/CachedRpcClient.cs
@@ -11,6 +11,7 @@ namespace WalletWasabi.BitcoinCore
public class CachedRpcClient : RpcClientBase
{
private CancellationTokenSource _tipChangeCancellationTokenSource;
+ private object CancellationTokenSourceLock { get; } = new object();
public CachedRpcClient(RPCClient rpc, IMemoryCache cache)
: base(rpc)
@@ -23,11 +24,14 @@ namespace WalletWasabi.BitcoinCore
private CancellationTokenSource TipChangeCancellationTokenSource
{
get
+ {
+ lock (CancellationTokenSourceLock)
{
if (_tipChangeCancellationTokenSource is null || _tipChangeCancellationTokenSource.IsCancellationRequested)
{
_tipChangeCancellationTokenSource = new CancellationTokenSource();
}
+ }
return _tipChangeCancellationTokenSource;
}
}

Add lock around CTS access