Example #1
0
        protected virtual void SetupAdminNotifications()
        {
            if (clusterConfig.Notifications?.Admin?.Enabled == true)
            {
                if (clusterConfig.Notifications?.Admin?.NotifyBlockFound == true)
                {
                    var adminEmail = clusterConfig.Notifications.Admin.EmailAddress;

                    var emailSender = notificationSenders
                                      .Where(x => x.Metadata.NotificationType == NotificationType.Email)
                                      .Select(x => x.Value)
                                      .First();

                    disposables.Add(Shares
                                    .ObserveOn(TaskPoolScheduler.Default)
                                    .Where(x => x.IsBlockCandidate)
                                    .Subscribe(async share =>
                    {
                        try
                        {
                            await emailSender.NotifyAsync(adminEmail, "Block Notification", $"Pool {share.PoolId} found block candidate {share.BlockHeight}");
                        }

                        catch (Exception ex)
                        {
                            logger.Error(ex);
                        }
                    }));
                }
            }
        }
Example #2
0
        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());
        }