private async Task CalculateBlockEffortAsync(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 = await cf.Run(con => blockRepo.GetBlockBeforeAsync(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 = await cf.Run(con => shareRepo.GetAccumulatedShareDifficultyBetweenCreatedAsync(con, pool.Id, from, to)); // handler has the final say if (accumulatedShareDiffForBlock.HasValue) { await handler.CalculateBlockEffortAsync(block, accumulatedShareDiffForBlock.Value); } }