示例#1
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);
        }
示例#2
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;
        }