/// <summary> /// Constructor /// </summary> /// <param name="houseAccountAlerter">House account alerter</param> /// <param name="houseBalanceConfiguration">House balance configuration</param> public LowBalanceWatcher(IHouseAccountAlerter houseAccountAlerter, IHouseBalanceConfiguration houseBalanceConfiguration) { if (houseAccountAlerter == null) { throw new ArgumentNullException(nameof(houseAccountAlerter)); } this._houseBalanceConfiguration = houseBalanceConfiguration ?? throw new ArgumentNullException(nameof(houseBalanceConfiguration)); this._houseAccounts = new ConcurrentDictionary <NetworkAccount, bool>(); this._subscription = Observable.FromEventPattern <EthereumBalanceChangeEventArgs>(addHandler: h => houseAccountAlerter.OnEthereumBalanceChanged += h, removeHandler: h => houseAccountAlerter.OnEthereumBalanceChanged -= h) .Select(e => e.EventArgs) .Subscribe(e => this.UpdateBalanceStatus((NetworkAccount)e.Account, ethereumAmount: e.NewBalance)); }
/// <summary> /// Constructor. /// </summary> /// <param name="drainedFaucetAlerter">Drained faucet alerting.</param> /// <param name="houseAccountAlerter">House account alerting.</param> /// <param name="logger">Logging.</param> public LowBalanceWatcherService(IDrainedFaucetAlerter drainedFaucetAlerter, IHouseAccountAlerter houseAccountAlerter, ILogger <LowBalanceWatcherService> logger) : base(TimeSpan.FromSeconds(15), logger: logger) { this._drainedFaucetAlerter = drainedFaucetAlerter ?? throw new ArgumentNullException(nameof(drainedFaucetAlerter)); this._houseAccountAlerter = houseAccountAlerter ?? throw new ArgumentNullException(nameof(houseAccountAlerter)); }