Handle long ban
MODIFY
WalletWasabi/WabiSabi/Backend/Banning/Prison.cs
WalletWasabi/WabiSabi/Backend/Banning/Prison.cs
@@ -41,9 +41,9 @@ public class Prison
Punish(alice.Coin.Outpoint, Punishment.Noted, lastDisruptedRoundId);
}
- public void Ban(Alice alice, uint256 lastDisruptedRoundId)
+ public void Ban(Alice alice, uint256 lastDisruptedRoundId, bool isLongBan = false)
{
- Punish(alice.Coin.Outpoint, Punishment.Banned, lastDisruptedRoundId);
+ Punish(alice.Coin.Outpoint, Punishment.Banned, lastDisruptedRoundId, isLongBan);
}
public void Ban(OutPoint outpoint, uint256 lastDisruptedRoundId)
@@ -51,8 +51,8 @@ public class Prison
Punish(outpoint, Punishment.Banned, lastDisruptedRoundId);
}
- public void Punish(OutPoint utxo, Punishment punishment, uint256 lastDisruptedRoundId)
- => Punish(new Inmate(utxo, punishment, DateTimeOffset.UtcNow, lastDisruptedRoundId));
+ public void Punish(OutPoint utxo, Punishment punishment, uint256 lastDisruptedRoundId, bool isLongBan = false)
+ => Punish(new Inmate(utxo, punishment, DateTimeOffset.UtcNow, lastDisruptedRoundId, isLongBan));
public void Punish(Inmate inmate)
{
@@ -92,7 +92,7 @@ public class Prison
}
}
- public IEnumerable<Inmate> ReleaseEligibleInmates(TimeSpan time)
+ public IEnumerable<Inmate> ReleaseEligibleInmates(TimeSpan normalBanTime, TimeSpan longBanTime)
{
lock (Lock)
{
@@ -100,6 +100,7 @@ public class Prison
foreach (var inmate in Inmates.Values.ToList())
{
+ var time = inmate.IsLongBan ? longBanTime : normalBanTime;
if (inmate.TimeSpent > time)
{
Inmates.Remove(inmate.Utxo);

MODIFY
WalletWasabi/WabiSabi/Backend/Banning/Warden.cs
WalletWasabi/WabiSabi/Backend/Banning/Warden.cs
@@ -73,7 +73,8 @@ public class Warden : PeriodicRunner
protected override async Task ActionAsync(CancellationToken cancel)
{
- var count = Prison.ReleaseEligibleInmates(Config.ReleaseUtxoFromPrisonAfter).Count();
+ var count = Prison.ReleaseEligibleInmates(Config.ReleaseUtxoFromPrisonAfter, Config.ReleaseUtxoFromPrisonAfterLongBan).Count();
+
if (count > 0)
{
Logger.LogInfo($"{count} UTXOs are released from prison.");

Handle long ban