public void Ban(IPAddress address, TimeSpan duration)
        {
            Assertion.RequiresNonNull(address, nameof(address));
            Assertion.Requires <ArgumentException>(duration.TotalMilliseconds > 0, $"{nameof(duration)} must not be empty");

            cache.Set(address.ToString(), string.Empty, duration);
        }
        public bool IsBanned(IPAddress address)
        {
            Assertion.RequiresNonNull(address, nameof(address));

            var result = cache.Get(address.ToString());

            return(result != null);
        }
示例#3
0
        public byte[] WithFirst(byte[] first)
        {
            Assertion.RequiresNonNull(first, nameof(first));

            foreach (var step in Steps)
            {
                first = DoubleDigest(first.Concat(step)).ToArray();
            }

            return(first);
        }
示例#4
0
        private IList <byte[]> CalculateSteps(IEnumerable <byte[]> hashList)
        {
            Assertion.RequiresNonNull(hashList, nameof(hashList));

            var steps = new List <byte[]>();

            var L = new List <byte[]> {
                null
            };

            L.AddRange(hashList);

            var startL = 2;
            var Ll     = L.Count;

            if (Ll > 1)
            {
                while (true)
                {
                    if (Ll == 1)
                    {
                        break;
                    }

                    steps.Add(L[1]);

                    if (Ll % 2 == 1)
                    {
                        L.Add(L[L.Count - 1]);
                    }

                    var Ld = new List <byte[]>();

                    for (var i = startL; i < Ll; i += 2)
                    {
                        Ld.Add(MerkleJoin(L[i], L[i + 1]));
                    }

                    L = new List <byte[]> {
                        null
                    };
                    L.AddRange(Ld);
                    Ll = L.Count;
                }
            }
            return(steps);
        }
        private static BitcoinCoinProperties GetVergeProperties(string algorithm)
        {
            Assertion.Requires <ArgumentException>(!string.IsNullOrEmpty(algorithm), $"{nameof(algorithm)} must not be empty");

            switch (algorithm.ToLower())
            {
            case "lyra":
                return(vergeLyraCoin);

            case "groestl":
                return(vergeGroestlCoin);

            case "x17":
                return(vergeX17Coin);

            case "blake":
                return(vergeBlake2sCoin);

            default:                     return(vergeScryptCoin);
            }
        }
示例#6
0
        public PayoutManager(IComponentContext ctx,
                             IConnectionFactory cf,
                             IBlockRepository blockRepo,
                             IShareRepository shareRepo,
                             IBalanceRepository balanceRepo,
                             WebhookNotificationService notificationService)
        {
            Assertion.RequiresNonNull(ctx, nameof(ctx));
            Assertion.RequiresNonNull(cf, nameof(cf));
            Assertion.RequiresNonNull(blockRepo, nameof(blockRepo));
            Assertion.RequiresNonNull(shareRepo, nameof(shareRepo));
            Assertion.RequiresNonNull(balanceRepo, nameof(balanceRepo));
            Assertion.RequiresNonNull(notificationService, nameof(notificationService));

            this.ctx                 = ctx;
            this.cf                  = cf;
            this.blockRepo           = blockRepo;
            this.shareRepo           = shareRepo;
            this.balanceRepo         = balanceRepo;
            this.notificationService = notificationService;
        }
        private static BitcoinCoinProperties GetDigiByteProperties(string algorithm)
        {
            Assertion.Requires <ArgumentException>(!string.IsNullOrEmpty(algorithm), $"{nameof(algorithm)} must not be empty");

            switch (algorithm.ToLower())
            {
            case "sha256d":
            case "sha256":
                return(sha256Coin);

            case "skein":
                return(skeinCoin);

            case "qubit":
                return(qubitCoin);

            case "groestl":
            case "groestl-myriad":
                return(groestlMyriadCoin);

            default:                     return(scryptCoin);
            }
        }