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 void GetTriggerInformation_ConsensusCommand_IsNull() { var dPoSTriggerInformation = CommandInput.Parser.ParseFrom( _consensusInformationGenerationService.GetTriggerInformation( TriggerType.ConsensusCommand).ToByteString() ); dPoSTriggerInformation.ShouldNotBeNull(); dPoSTriggerInformation.PublicKey.ToHex().ShouldBe(_accountService.GetPublicKeyAsync().Result.ToHex()); }