Example #1
0
    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;
    }
Example #2
0
    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);
    }
Example #3
0
    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);
    }
Example #4
0
    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);
    }
Example #5
0
 public WabiSabiController(IdempotencyRequestCache idempotencyRequestCache, Arena arena, CoinJoinFeeRateStatStore coinJoinFeeRateStatStore)
 {
     IdempotencyRequestCache = idempotencyRequestCache;
     Arena = arena;
     CoinJoinFeeRateStatStore = coinJoinFeeRateStatStore;
 }