/// <summary> /// This method should return true if all the BPs restarted (and missed their time slots). /// </summary> /// <returns></returns> public bool CanRecoverDPoSInformation() { try { //If DPoS information is already generated, return false; //Because this method doesn't responsible to initialize DPoS information. if (CurrentRoundNumber.Value == 0) { return(false); } var extraBlockTimeSlot = ExtraBlockTimeSlot.ToDateTime(); var now = DateTime.UtcNow; if (now < extraBlockTimeSlot) { return(false); } } catch (Exception e) { _logger?.Error(e, "Failed to check whether this node can recover DPoS mining."); return(false); } return(true); }
// ReSharper disable once UnusedMember.Global public StringValue GetDPoSInfoToString() { ulong count = 1; if (CurrentRoundNumber.Value != 0) { count = CurrentRoundNumber.Value; } var infoOfOneRound = ""; ulong i = 1; while (i <= count) { var roundInfoStr = GetRoundInfoToString(new UInt64Value { Value = i }); infoOfOneRound += $"\n[Round {i}]\n" + roundInfoStr; i++; } var res = new StringValue { Value = infoOfOneRound + $"EBP Time Slot of current round: {ExtraBlockTimeSlot.ToDateTime().ToLocalTime():u}\n" + "Current Round : " + CurrentRoundNumber?.Value }; return(res); }
private string GetDPoSInfoToStringOfLatestRounds(ulong countOfRounds) { try { if (CurrentRoundNumber.Value == 0) { return("Somehow current round number is 0"); } if (countOfRounds == 0) { return(""); } var currentRoundNumber = CurrentRoundNumber.Value; ulong startRound; if (countOfRounds >= currentRoundNumber) { startRound = 1; } else { startRound = currentRoundNumber - countOfRounds + 1; } var infoOfOneRound = ""; var i = startRound; while (i <= currentRoundNumber) { if (i <= 0) { continue; } var roundInfoStr = GetRoundInfoToString(new UInt64Value { Value = i }); infoOfOneRound += $"\n[Round {i}]\n" + roundInfoStr; i++; } return (infoOfOneRound + $"EBP TimeSlot of current round: {ExtraBlockTimeSlot.ToDateTime().ToLocalTime():u}\n" + $"Current Round : {CurrentRoundNumber.Value}"); } catch (Exception e) { _logger?.Error(e, "Failed to get dpos info"); return(""); } }