Make ID be a Guid
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/UtxoPrisonTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/UtxoPrisonTests.cs
@@ -30,20 +30,22 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
// Make sure we set them to the past so the release method that looks at the time evaluates to true.
var past = DateTimeOffset.UtcNow - TimeSpan.FromMilliseconds(2);
- p.Punish(new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, past, 1));
+ var guid1 = Guid.NewGuid();
+ p.Punish(new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, past, guid1));
Assert.NotEqual(currentChangeId, p.ChangeId);
currentChangeId = p.ChangeId;
- p.Punish(new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, past, 1));
+ p.Punish(new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, past, guid1));
Assert.NotEqual(currentChangeId, p.ChangeId);
currentChangeId = p.ChangeId;
var op = BitcoinFactory.CreateOutPoint();
- p.Punish(new Inmate(op, Punishment.Noted, past, 2));
+ var guid2 = Guid.NewGuid();
+ p.Punish(new Inmate(op, Punishment.Noted, past, guid2));
Assert.NotEqual(currentChangeId, p.ChangeId);
currentChangeId = p.ChangeId;
- p.Punish(new Inmate(op, Punishment.Noted, past, 1));
+ p.Punish(new Inmate(op, Punishment.Noted, past, guid1));
Assert.NotEqual(currentChangeId, p.ChangeId);
currentChangeId = p.ChangeId;
@@ -60,15 +62,17 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
var p = new Prison(Enumerable.Empty<Inmate>());
+ var guid1 = Guid.NewGuid();
+
var utxo = BitcoinFactory.CreateOutPoint();
- p.Punish(utxo, Punishment.Noted, 1);
+ p.Punish(utxo, Punishment.Noted, guid1);
Assert.Single(p.GetInmates());
Assert.Equal(1, p.CountInmates().noted);
Assert.Equal(0, p.CountInmates().banned);
Assert.True(p.TryGet(utxo, out _));
// Updates to banned.
- p.Punish(utxo, Punishment.Banned, 1);
+ p.Punish(utxo, Punishment.Banned, guid1);
Assert.Single(p.GetInmates());
Assert.Equal(0, p.CountInmates().noted);
Assert.Equal(1, p.CountInmates().banned);
@@ -79,8 +83,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
Assert.Empty(p.GetInmates());
// Noting twice flips to banned.
- p.Punish(utxo, Punishment.Noted, 1);
- p.Punish(utxo, Punishment.Noted, 1);
+ p.Punish(utxo, Punishment.Noted, guid1);
+ p.Punish(utxo, Punishment.Noted, guid1);
Assert.Single(p.GetInmates());
Assert.Equal(0, p.CountInmates().noted);
Assert.Equal(1, p.CountInmates().banned);
@@ -88,11 +92,12 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
Assert.True(p.TryRelease(utxo, out _));
// Updates round.
- p.Punish(utxo, Punishment.Banned, 1);
- p.Punish(utxo, Punishment.Banned, 2);
+ var guid2 = Guid.NewGuid();
+ p.Punish(utxo, Punishment.Banned, guid1);
+ p.Punish(utxo, Punishment.Banned, guid2);
Assert.Single(p.GetInmates());
Assert.True(p.TryGet(utxo, out var inmate));
- Assert.Equal(2ul, inmate!.LastDisruptedRoundId);
+ Assert.Equal(guid2, inmate!.LastDisruptedRoundId);
Assert.True(p.TryRelease(utxo, out _));
}
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/UtxoPrisonWardenTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/UtxoPrisonWardenTests.cs
@@ -35,8 +35,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
CoordinatorParameters coordinatorParameters = new(workDir);
using var w = new Warden(coordinatorParameters.UtxoWardenPeriod, coordinatorParameters.PrisonFilePath, coordinatorParameters.RuntimeCoordinatorConfig);
await w.StartAsync(CancellationToken.None);
- var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 1);
- var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 2);
+ var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
+ var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
w.Prison.Punish(i1);
w.Prison.Punish(i2);
@@ -72,8 +72,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
CoordinatorParameters coordinatorParameters = new(workDir);
using var w = new Warden(coordinatorParameters.UtxoWardenPeriod, coordinatorParameters.PrisonFilePath, coordinatorParameters.RuntimeCoordinatorConfig);
await w.StartAsync(CancellationToken.None);
- var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 1);
- var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 2);
+ var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
+ var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
w.Prison.Punish(i1);
w.Prison.Punish(i2);
@@ -99,8 +99,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
using var w = new Warden(coordinatorParameters.UtxoWardenPeriod, coordinatorParameters.PrisonFilePath, coordinatorParameters.RuntimeCoordinatorConfig);
await w.StartAsync(CancellationToken.None);
- var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 1);
- var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), 2);
+ var i1 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Noted, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
+ var i2 = new Inmate(BitcoinFactory.CreateOutPoint(), Punishment.Banned, DateTimeOffset.FromUnixTimeSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds()), Guid.NewGuid());
var p = w.Prison;
p.Punish(i1);
p.Punish(i2);

MODIFY
WalletWasabi/WabiSabi/Backend/Banning/Inmate.cs
WalletWasabi/WabiSabi/Backend/Banning/Inmate.cs
@@ -13,7 +13,7 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
/// </summary>
public class Inmate
{
- public Inmate(OutPoint utxo, Punishment punishment, DateTimeOffset started, ulong lastDisruptedRoundId)
+ public Inmate(OutPoint utxo, Punishment punishment, DateTimeOffset started, Guid lastDisruptedRoundId)
{
Utxo = utxo;
Punishment = punishment;
@@ -24,7 +24,7 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
public OutPoint Utxo { get; }
public Punishment Punishment { get; }
public DateTimeOffset Started { get; }
- public ulong LastDisruptedRoundId { get; }
+ public Guid LastDisruptedRoundId { get; }
public TimeSpan TimeSpent => DateTimeOffset.UtcNow - Started;
@@ -41,7 +41,7 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
var started = DateTimeOffset.FromUnixTimeSeconds(long.Parse(startedString));
var punishment = Enum.Parse<Punishment>(punishmentString);
var utxo = new OutPoint(new uint256(utxoHashString), int.Parse(utxoIndexString));
- var lastDisruptedRoundId = ulong.Parse(disruptedRoundIdString);
+ var lastDisruptedRoundId = Guid.Parse(disruptedRoundIdString);
return new(utxo, punishment, started, lastDisruptedRoundId);
}

MODIFY
WalletWasabi/WabiSabi/Backend/Banning/Prison.cs
WalletWasabi/WabiSabi/Backend/Banning/Prison.cs
@@ -32,7 +32,7 @@ namespace WalletWasabi.WabiSabi.Backend.Banning
}
}
- public void Punish(OutPoint utxo, Punishment punishment, ulong lastDisruptedRoundId)
+ public void Punish(OutPoint utxo, Punishment punishment, Guid lastDisruptedRoundId)
=> Punish(new Inmate(utxo, punishment, DateTimeOffset.UtcNow, lastDisruptedRoundId));
public void Punish(Inmate inmate)

Make ID be a Guid