コード例 #1
0
ファイル: PoolBase.cs プロジェクト: SolarPool/miningcore_ella
        protected void ConsiderBan(StratumClient <TWorkerContext> client, WorkerContextBase context, PoolBanningConfig config)
        {
            var totalShares = context.Stats.ValidShares + context.Stats.InvalidShares;

            if (totalShares > config.CheckThreshold)
            {
                var ratioBad = (double)context.Stats.InvalidShares / totalShares;

                if (ratioBad < config.InvalidPercent / 100.0)
                {
                    // reset stats
                    context.Stats.ValidShares   = 0;
                    context.Stats.InvalidShares = 0;
                }

                else
                {
                    logger.Warn(() => $"[{LogCat}] [{client.ConnectionId}] Banning worker for {config.Time} sec: {Math.Floor(ratioBad * 100)}% of the last {totalShares} shares were invalid");

                    banManager.Ban(client.RemoteEndpoint.Address, TimeSpan.FromSeconds(config.Time));

                    DisconnectClient(client);
                }
            }
        }
コード例 #2
0
ファイル: PoolBase.cs プロジェクト: zhq1/miningcore
        protected void ConsiderBan(StratumClient client, WorkerContextBase context, PoolShareBasedBanningConfig config)
        {
            var totalShares = context.Stats.ValidShares + context.Stats.InvalidShares;

            if (totalShares > config.CheckThreshold)
            {
                var ratioBad = (double)context.Stats.InvalidShares / totalShares;

                if (ratioBad < config.InvalidPercent / 100.0)
                {
                    // reset stats
                    context.Stats.ValidShares   = 0;
                    context.Stats.InvalidShares = 0;
                }

                else
                {
                    if (poolConfig.Banning?.Enabled == true &&
                        (clusterConfig.Banning?.BanOnInvalidShares.HasValue == false ||
                         clusterConfig.Banning?.BanOnInvalidShares == true))
                    {
                        logger.Info(() => $"[{client.ConnectionId}] Banning worker for {config.Time} sec: {Math.Floor(ratioBad * 100)}% of the last {totalShares} shares were invalid");

                        banManager.Ban(client.RemoteEndpoint.Address, TimeSpan.FromSeconds(config.Time));

                        DisconnectClient(client);
                    }
                }
            }
        }