コード例 #1
0
        private async Task CalculateBlockEffort(PoolConfig pool, Block block, IPayoutHandler handler)
        {
            // get share date-range
            var from = DateTime.MinValue;
            var to   = block.Created;

            // get last block for pool
            var lastBlock = cf.Run(con => blockRepo.GetBlockBefore(con, pool.Id, new[]
            {
                BlockStatus.Confirmed,
                BlockStatus.Orphaned,
                BlockStatus.Pending,
            }, block.Created));

            if (lastBlock != null)
            {
                from = lastBlock.Created;
            }

            // get combined diff of all shares for block
            var accumulatedShareDiffForBlock = cf.Run(con =>
                                                      shareRepo.GetAccumulatedShareDifficultyBetweenCreated(con, pool.Id, from, to));

            // handler has the final say
            if (accumulatedShareDiffForBlock.HasValue)
            {
                await handler.CalculateBlockEffortAsync(block, accumulatedShareDiffForBlock.Value);
            }
        }
コード例 #2
0
        private async Task CalculateBlockEffort(PoolConfig pool, Block block, IPayoutHandler handler)
        {
            var from = DateTime.MinValue;
            var to   = block.Created;

            var lastBlock = cf.Run(con => blockRepo.GetBlockBefore(con, pool.Id, new[]
            {
                BlockStatus.Confirmed,
                BlockStatus.Orphaned,
                BlockStatus.Pending,
            }, block.Created));

            if (lastBlock != null)
            {
                from = lastBlock.Created;
            }

            var accumulatedShareDiffForBlock = cf.Run(con =>
                                                      shareRepo.GetAccumulatedShareDifficultyBetweenCreated(con, pool.Id, from, to));

            if (accumulatedShareDiffForBlock.HasValue)
            {
                await handler.CalculateBlockEffortAsync(block, accumulatedShareDiffForBlock.Value);
            }
        }