Single Random instance
MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -37,6 +37,7 @@ namespace WalletWasabi.Services
public static event EventHandler<bool> DownloadingBlockChanged;
public static event EventHandler<bool> InitializingChanged;
+ private static Random Random { get; } = new Random();
public BitcoinStore BitcoinStore { get; }
public KeyManager KeyManager { get; }
@@ -735,15 +736,14 @@ namespace WalletWasabi.Services
// 1.85% uses up to 5 blocks in the future (we don't do this)
// 0.65% uses an uniform random from -1 to -99
- var randomGenerator = new Random();
// sometimes pick locktime a bit further back, to help privacy.
- var randomValue = randomGenerator.NextDouble();
+ var randomValue = Random.NextDouble();
return randomValue switch
{
var r when r < (0.9) => LockTime.Zero,
var r when r < (0.9 + 0.075) => tipHeight,
var r when r < (0.9 + 0.075 + 0.0065) => (uint)(tipHeight + 1),
- _ => (uint)(tipHeight - randomGenerator.Next(1, 100))
+ _ => (uint)(tipHeight - Random.Next(1, 100))
};
}
catch

Single Random instance