public async Task TriggerConsensusAsync(ChainContext chainContext) { var triggerInformation = _consensusInformationGenerationService.GetTriggerInformation(TriggerType.ConsensusCommand); // Upload the consensus command. _consensusControlInformation.ConsensusCommand = await _consensusInformationGenerationService.ExecuteContractAsync <ConsensusCommand>(chainContext, ConsensusConsts.GetConsensusCommand, triggerInformation, DateTime.UtcNow); Logger.LogDebug($"Updated consensus command: {_consensusControlInformation.ConsensusCommand}"); // Initial consensus scheduler. var blockMiningEventData = new ConsensusRequestMiningEventData(chainContext.BlockHash, chainContext.BlockHeight, _consensusControlInformation.ConsensusCommand.ExpectedMiningTime.ToDateTime(), TimeSpan.FromMilliseconds(_consensusControlInformation.ConsensusCommand .LimitMillisecondsOfMiningBlock)); _consensusScheduler.CancelCurrentEvent(); // TODO: Remove NextBlockMiningLeftMilliseconds. _consensusScheduler.NewEvent(_consensusControlInformation.ConsensusCommand.NextBlockMiningLeftMilliseconds, blockMiningEventData); // Update next mining time, also block time of both getting consensus extra data and txs. _nextMiningTime = DateTime.UtcNow.AddMilliseconds(_consensusControlInformation.ConsensusCommand .NextBlockMiningLeftMilliseconds); }
public async Task <IEnumerable <string> > GetCurrentMiners(ChainContext chainContext) { var minersWithRoundNumber = await _consensusInformationGenerationService.ExecuteContractAsync <MinerListWithRoundNumber>(chainContext, "GetCurrentMiners", new Empty(), DateTime.UtcNow); return(minersWithRoundNumber.MinerList.PublicKeys); }