/// <summary>
        /// Basically update the consensus scheduler with latest consensus command.
        /// </summary>
        /// <param name="chainContext"></param>
        /// <returns></returns>
        public async Task TriggerConsensusAsync(ChainContext chainContext)
        {
            var now = TimestampHelper.GetUtcNow();

            _blockTimeProvider.SetBlockTime(now);

            Logger.LogDebug($"Set block time to utc now: {now.ToDateTime():hh:mm:ss.ffffff}. Trigger.");

            var triggerInformation =
                _triggerInformationProvider.GetTriggerInformationForConsensusCommand(new BytesValue());

            Logger.LogDebug($"Mining triggered, chain context: {chainContext.BlockHeight} - {chainContext.BlockHash}");

            // Upload the consensus command.
            var contractReaderContext =
                await _consensusReaderContextService.GetContractReaderContextAsync(chainContext);

            _consensusCommand = await _contractReaderFactory
                                .Create(contractReaderContext).GetConsensusCommand
                                .CallAsync(triggerInformation);

            if (_consensusCommand == null)
            {
                Logger.LogWarning("Consensus command is null.");
                return;
            }

            Logger.LogDebug($"Updated consensus command: {_consensusCommand}");

            // Update next mining time, also block time of both getting consensus extra data and txs.
            _nextMiningTime = _consensusCommand.ArrangedMiningTime;
            var leftMilliseconds = _consensusCommand.ArrangedMiningTime - TimestampHelper.GetUtcNow();

            leftMilliseconds = leftMilliseconds.Seconds > ConsensusConstants.MaximumLeftMillisecondsForNextBlock
                ? new Duration {
                Seconds = ConsensusConstants.MaximumLeftMillisecondsForNextBlock
            }
                : leftMilliseconds;

            // Update consensus scheduler.
            var blockMiningEventData = new ConsensusRequestMiningEventData(chainContext.BlockHash,
                                                                           chainContext.BlockHeight,
                                                                           _nextMiningTime,
                                                                           TimestampHelper.DurationFromMilliseconds(_consensusCommand.LimitMillisecondsOfMiningBlock),
                                                                           _consensusCommand.MiningDueTime);

            _consensusScheduler.CancelCurrentEvent();
            _consensusScheduler.NewEvent(leftMilliseconds.Milliseconds(), blockMiningEventData);

            Logger.LogDebug($"Set next mining time to: {_nextMiningTime.ToDateTime():hh:mm:ss.ffffff}");
        }
        public async Task <IEnumerable <string> > GetCurrentMinerList(ChainContext chainContext)
        {
            var contractReaderContext =
                await _consensusReaderContextService.GetContractReaderContextAsync(chainContext);

            var minersWithRoundNumber =
                await _contractReaderFactory
                .Create(contractReaderContext).GetCurrentMinerList.CallAsync(new Empty());

            return(minersWithRoundNumber.Pubkeys.Select(k => k.ToHex()));
        }