Remove CoinJoinFeeRateStatStore from Arena
MODIFY
WalletWasabi.Backend/Controllers/WabiSabiController.cs
WalletWasabi.Backend/Controllers/WabiSabiController.cs
@@ -5,6 +5,7 @@ using WalletWasabi.Backend.Controllers.WabiSabi;
using WalletWasabi.Backend.Filters;
using WalletWasabi.WabiSabi.Backend.PostRequests;
using WalletWasabi.WabiSabi.Backend.Rounds;
+using WalletWasabi.WabiSabi.Backend.Statistics;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.Backend.Controllers;
@@ -15,19 +16,23 @@ namespace WalletWasabi.Backend.Controllers;
[Produces("application/json")]
public class WabiSabiController : ControllerBase, IWabiSabiApiRequestHandler
{
- public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena)
+ public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena, CoinJoinFeeRateStatStore coinJoinFeeRateStatStore)
{
IdempotencyRequestCache = idempotencyRequestCache;
Arena = arena;
+ CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore;
}
private IdempotencyRequestCache IdempotencyRequestCache { get; }
private Arena Arena { get; }
+ private CoinJoinFeeRateStatStore CoinJoinFeeRateStatStore { get; }
[HttpPost("status")]
- public Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
+ public async Task<RoundStateResponse> GetStatusAsync(RoundStateRequest request, CancellationToken cancellationToken)
{
- return Arena.GetStatusAsync(request, cancellationToken);
+ var response = await Arena.GetStatusAsync(request, cancellationToken);
+ var avarages = CoinJoinFeeRateStatStore.GetDefaultAvarages();
+ return new RoundStateResponse(response.RoundStates, avarages);
}
[HttpPost("connection-confirmation")]

MODIFY
WalletWasabi.Backend/Startup.cs
WalletWasabi.Backend/Startup.cs
@@ -75,6 +75,12 @@ public class Startup
var coordinator = global.HostedServices.Get<WabiSabiCoordinator>();
return coordinator.Arena;
});
+ services.AddSingleton(serviceProvider =>
+ {
+ var global = serviceProvider.GetRequiredService<Global>();
+ var coordinator = global.HostedServices.Get<WabiSabiCoordinator>();
+ return coordinator.CoinJoinFeeRateStatStore;
+ });
services.AddStartupTask<InitConfigStartupTask>();
services.AddResponseCompression();

MODIFY
WalletWasabi.Tests/Helpers/ArenaBuilder.cs
WalletWasabi.Tests/Helpers/ArenaBuilder.cs
@@ -37,9 +37,8 @@ public class ArenaBuilder
IRPCClient rpc = Rpc ?? WabiSabiFactory.CreatePreconfiguredRpcClient().Object;
Network network = Network ?? Network.Main;
InMemoryCoinJoinIdStore coinJoinIdStore = CoinJoinIdStore ?? new();
- CoinJoinFeeRateStatStore coinJoinFeeRateStatStore = CoinJoinFeeRateStatStore ?? new(config, rpc, Enumerable.Empty<CoinJoinFeeRateStatRecord>());
- Arena arena = new(period, network, config, rpc, prison, coinJoinIdStore, coinJoinFeeRateStatStore);
+ Arena arena = new(period, network, config, rpc, prison, coinJoinIdStore);
foreach (var round in rounds)
{

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
@@ -367,7 +367,7 @@ public partial class Arena : IWabiSabiApiRequestHandler
return RoundState.FromRound(x, checkPoint == default ? 0 : checkPoint.StateId);
}).ToArray();
- return new RoundStateResponse(roundStates, CoinJoinFeeRateStatStore.GetDefaultAvarages());
+ return new RoundStateResponse(roundStates, Array.Empty<CoinJoinFeeRateAvarage>());
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -26,7 +26,6 @@ public partial class Arena : PeriodicRunner
IRPCClient rpc,
Prison prison,
InMemoryCoinJoinIdStore inMemoryCoinJoinIdStore,
- CoinJoinFeeRateStatStore coinJoinFeeRateStatStore,
CoinJoinTransactionArchiver? archiver = null) : base(period)
{
Network = network;
@@ -36,7 +35,6 @@ public partial class Arena : PeriodicRunner
TransactionArchiver = archiver;
Random = new SecureRandom();
InMemoryCoinJoinIdStore = inMemoryCoinJoinIdStore;
- CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore;
}
public HashSet<Round> Rounds { get; } = new();
@@ -48,7 +46,6 @@ public partial class Arena : PeriodicRunner
private SecureRandom Random { get; }
private CoinJoinTransactionArchiver? TransactionArchiver { get; }
private InMemoryCoinJoinIdStore InMemoryCoinJoinIdStore { get; }
- private CoinJoinFeeRateStatStore CoinJoinFeeRateStatStore { get; }
public event EventHandler<Transaction>? CoinJoinBroadcast;

MODIFY
WalletWasabi/WabiSabi/Backend/Statistics/CoinJoinFeeRateStatStore.cs
WalletWasabi/WabiSabi/Backend/Statistics/CoinJoinFeeRateStatStore.cs
@@ -52,7 +52,7 @@ public class CoinJoinFeeRateStatStore : PeriodicRunner
{
CoinJoinFeeRateStatRecords.Add(feeRateStatRecord);
- DefaultAvarages = TimeFrames.Select(t => new CoinJoinFeeRateAvarage((int)Math.Floor(t.TotalHours), GetAvarage(t))).ToArray();
+ DefaultAvarages = TimeFrames.Select(t => new CoinJoinFeeRateAvarage(t, GetAvarage(t))).ToArray();
// Prune old items.
DateTimeOffset removeBefore = DateTimeOffset.UtcNow - MaximumTimeToStore;

MODIFY
WalletWasabi/WabiSabi/Models/CoinJoinFeeRateAvarage.cs
WalletWasabi/WabiSabi/Models/CoinJoinFeeRateAvarage.cs
@@ -2,4 +2,4 @@ using NBitcoin;
namespace WalletWasabi.WabiSabi.Models;
-public record CoinJoinFeeRateAvarage(int TimeFrameHours, FeeRate AvarageFeeRate);
+public record CoinJoinFeeRateAvarage(TimeSpan TimeFrame, FeeRate AvarageFeeRate);

MODIFY
WalletWasabi/WabiSabi/WabiSabiCoordinator.cs
WalletWasabi/WabiSabi/WabiSabiCoordinator.cs
@@ -31,7 +31,7 @@ public class WabiSabiCoordinator : BackgroundService
var inMemoryCoinJoinIdStore = InMemoryCoinJoinIdStore.LoadFromFile(parameters.CoinJoinIdStoreFilePath);
- Arena = new(parameters.RoundProgressSteppingPeriod, rpc.Network, Config, rpc, Warden.Prison, inMemoryCoinJoinIdStore, CoinJoinFeeRateStatStore, transactionArchiver);
+ Arena = new(parameters.RoundProgressSteppingPeriod, rpc.Network, Config, rpc, Warden.Prison, inMemoryCoinJoinIdStore, transactionArchiver);
Arena.CoinJoinBroadcast += Arena_CoinJoinBroadcast;
}

Remove CoinJoinFeeRateStatStore from Arena