protected override void SetupStats() { base.SetupStats(); // Pool Hashrate var poolHashRateSampleIntervalSeconds = 60 * 10; disposables.Add(Shares .Buffer(TimeSpan.FromSeconds(poolHashRateSampleIntervalSeconds)) .Do(shares => UpdateMinerHashrates(shares, poolHashRateSampleIntervalSeconds)) .Select(shares => { if (!shares.Any()) { return(0ul); } try { return(HashrateFromShares(shares, poolHashRateSampleIntervalSeconds)); } catch (Exception ex) { logger.Error(ex); return(0ul); } }) .Subscribe(hashRate => poolStats.PoolHashRate = hashRate)); }
protected virtual void SetupStats() { LoadStats(); // Periodically persist pool- and blockchain-stats to persistent storage disposables.Add(Observable.Interval(TimeSpan.FromSeconds(60)) .Select(_ => Observable.FromAsync(async() => { try { await UpdateBlockChainStatsAsync(); } catch (Exception) { // ignored } })) .Concat() .Subscribe(_ => PersistStats())); // For external stratums, miner counts are derived from submitted shares if (poolConfig.ExternalStratum) { disposables.Add(Shares .Buffer(TimeSpan.FromMinutes(1)) .Do(shares => { var sharesByMiner = shares.GroupBy(x => x.Share.Miner).ToArray(); poolStats.ConnectedMiners = sharesByMiner.Length; }) .Subscribe()); } }
protected override void SetupStats() { base.SetupStats(); // Pool Hashrate var poolHashRateSampleIntervalSeconds = 60 * 5; disposables.Add(Shares .ObserveOn(ThreadPoolScheduler.Instance) .Buffer(TimeSpan.FromSeconds(poolHashRateSampleIntervalSeconds)) .Do(shares => UpdateMinerHashrates(shares, poolHashRateSampleIntervalSeconds)) .Select(shares => { if (!shares.Any()) { return(0ul); } try { return(HashrateFromShares(shares, poolHashRateSampleIntervalSeconds)); } catch (Exception ex) { logger.Error(ex); return(0ul); } }) .Subscribe(hashRate => poolStats.PoolHashRate = hashRate)); // shares/sec disposables.Add(Shares .Buffer(TimeSpan.FromSeconds(1)) .Do(shares => { poolStats.ValidSharesPerSecond = shares.Count; logger.Debug(() => $"[{LogCat}] Share/sec = {poolStats.ValidSharesPerSecond}"); }) .Subscribe()); }