bool NodeInactive(RouterStatistics d) { if (d.InformationFaulty > 0) { return(true); } var result = (d.FailedTunnelTest > 8 && d.FailedTunnelTest > 3 * d.SuccessfulTunnelTest) || (d.FailedConnects > 5 && d.FailedConnects > 3 * d.SuccessfulConnects); return(result); }
public RouterStatistics this[I2PIdentHash ix] { get { if (!Routers.TryGetValue(ix, out var stat)) { stat = new RouterStatistics(ix); Routers[ix] = stat; } else { stat = Routers[ix]; } return(stat); } }
public void Load() { using (var s = GetStore()) { var readsw = new Stopwatch(); var constrsw = new Stopwatch(); var dicsw = new Stopwatch(); var sw2 = new Stopwatch(); sw2.Start(); var ix = 0; while ((ix = s.Next(ix)) > 0) { readsw.Start(); var data = s.Read(ix); readsw.Stop(); var reader = new BufRefLen(data); switch ((StoreRecordId)reader.Read32()) { case StoreRecordId.RouterStatistics: constrsw.Start(); var one = new RouterStatistics(reader); constrsw.Stop(); dicsw.Start(); Routers[one.Id] = one; dicsw.Stop(); one.StoreIx = ix; break; default: s.Delete(ix); break; } } sw2.Stop(); Logging.Log($"Statistics load: Total: {sw2.Elapsed}, " + $"Read(): {readsw.Elapsed}, Constr: {constrsw.Elapsed}, " + $"Dict: {dicsw.Elapsed} "); // var times = Destinations.Select( d => d.Value.TunnelBuildTimeMsPerHop.ToString() ); // System.IO.File.WriteAllLines( "/tmp/ct.txt", times ); } }