public void SetTopHeight(uint height) { TopHeight = height; if (LastHeight.HasValue) { if (FullBlockMesured) { LastBlockTimeDuration = (DateTime.UtcNow - LastHeight.Value); AverageBlocktime.Add((int)LastBlockTimeDuration.Value.TotalSeconds); } else { FullBlockMesured = true; } } LastHeight = DateTime.UtcNow; NextHeight = LastHeight.Value.AddSeconds((int)BlockTimeSeconds); if (LateHeightCount > 0) { LateHeightCount = 0; Program.AlarmManager.Clear(NetworkAlarm, $"CLEARED: Network Stall Alarm {Name}"); NetworkAlarm = null; } }
public void Update(clsNode node) { if (Name != node.Name) { throw new Exception("index name does not match"); } Group = node.Group; Host = node.Host; if (Monitor != node.Monitor) { Monitor = node.Monitor; HeightLowCount = 0; LatencyLowCount = 0; RequestFailCount = 0; Program.AlarmManager.Remove(AlarmSyncing); Program.AlarmManager.Remove(AlarmHeightLow); Program.AlarmManager.Remove(AlarmLatencyLow); Program.AlarmManager.Remove(AlarmRequestFail); AlarmSyncing = null; AlarmHeightLow = null; AlarmLatencyLow = null; AlarmRequestFail = null; } PostPopulate(); }
internal void Remove(clsAlarm Alarm) { if (Alarm != null && AlarmList.Contains(Alarm)) { AlarmList.Remove(Alarm); } }
public void Clear(clsAlarm Alarm, string message = null) { if (AlarmList.Contains(Alarm)) { Alarm.Clear(message); AlarmList.Remove(Alarm); } }
public void CheckStall() { if (NextHeight.HasValue && DateTime.UtcNow > NextHeight.Value) { var seconds = (DateTime.UtcNow - NextHeight).Value.TotalSeconds; if (seconds > BlockTimeSecondsAllowance) { if (MonitoringSources == 0) //No data sources, so we need to cancel { NextHeight = null; if (NetworkAlarm != null) { Program.AlarmManager.Remove(NetworkAlarm); NetworkAlarm = null; } } else if (++LateHeightCount == 1) { NetworkAlarm = new clsAlarm(clsAlarm.enumAlarmType.Network, $"WARNING: Network Height {seconds:0} sec late. {Name} stall or an election?", this); Program.AlarmManager.New(NetworkAlarm); } } } }
public void New(clsAlarm Alarm) { Alarm.Process(); AlarmList.Add(Alarm); }