public WabiSabiCoordinator(CoordinatorParameters parameters, IRPCClient rpc, ICoinJoinIdStore coinJoinIdStore) { Parameters = parameters; Warden = new(parameters.UtxoWardenPeriod, parameters.PrisonFilePath, Config); ConfigWatcher = new(parameters.ConfigChangeMonitoringPeriod, Config, () => Logger.LogInfo("WabiSabi configuration has changed.")); CoinJoinIdStore = coinJoinIdStore; CoinJoinTransactionArchiver transactionArchiver = new(Path.Combine(parameters.CoordinatorDataDir, "CoinJoinTransactions")); CoinJoinFeeRateStatStore = CoinJoinFeeRateStatStore.LoadFromFile(parameters.CoinJoinFeeRateStatStoreFilePath, Config, rpc); IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinFeeRateStatStoreFilePath); CoinJoinFeeRateStatStore.NewStat += FeeRateStatStore_NewStat; var coinJoinScriptStore = CoinJoinScriptStore.LoadFromFile(parameters.CoinJoinScriptStoreFilePath); IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinScriptStoreFilePath); RoundParameterFactory roundParameterFactory = new RoundParameterFactory(Config, rpc.Network); Arena = new( parameters.RoundProgressSteppingPeriod, rpc.Network, Config, rpc, Warden.Prison, coinJoinIdStore, roundParameterFactory, transactionArchiver, coinJoinScriptStore); IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinIdStoreFilePath); Arena.CoinJoinBroadcast += Arena_CoinJoinBroadcast; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await ConfigWatcher.StartAsync(stoppingToken).ConfigureAwait(false); await Warden.StartAsync(stoppingToken).ConfigureAwait(false); await Arena.StartAsync(stoppingToken).ConfigureAwait(false); await CoinJoinFeeRateStatStore.StartAsync(stoppingToken).ConfigureAwait(false); }
public override async Task StopAsync(CancellationToken cancellationToken) { await base.StopAsync(cancellationToken).ConfigureAwait(false); await Arena.StopAsync(cancellationToken).ConfigureAwait(false); await ConfigWatcher.StopAsync(cancellationToken).ConfigureAwait(false); await Warden.StopAsync(cancellationToken).ConfigureAwait(false); await CoinJoinFeeRateStatStore.StopAsync(cancellationToken).ConfigureAwait(false); }
public static CoinJoinFeeRateStatStore LoadFromFile(string filePath, WabiSabiConfig config, IRPCClient rpc) { var from = DateTimeOffset.UtcNow - MaximumTimeToStore; var stats = !File.Exists(filePath) ? Enumerable.Empty <CoinJoinFeeRateStat>() : File.ReadAllLines(filePath) .Select(x => CoinJoinFeeRateStat.FromLine(x)) .Where(x => x.DateTimeOffset >= from); var store = new CoinJoinFeeRateStatStore(config, rpc, stats); return(store); }
public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena, CoinJoinFeeRateStatStore coinJoinFeeRateStatStore) { IdempotencyRequestCache = idempotencyRequestCache; Arena = arena; CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore; }