I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0108c1c2 authored by zzz's avatar zzz
Browse files

i2psnark: Periodically DHT nodes (ticket #1328)

parent a8976d25
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
private final AtomicLong _rxBytes = new AtomicLong();
private final AtomicLong _txBytes = new AtomicLong();
private long _started;
private long _nodesLastSaved;
/** all-zero NID used for pings */
public static final NID FAKE_NID = new NID(new byte[NID.HASH_LENGTH]);
......@@ -156,6 +157,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
private static final long CLEAN_TIME = 63*1000;
private static final long EXPLORE_TIME = 877*1000;
private static final long BLACKLIST_CLEAN_TIME = 17*60*1000;
private static final long NODES_SAVE_TIME = 3*60*60*1000;
public static final String DHT_FILE_SUFFIX = ".dht.dat";
private static final int SEND_CRYPTO_TAGS = 8;
......@@ -635,6 +637,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
_txBytes.set(0);
_rxBytes.set(0);
_started = _context.clock().now();
_nodesLastSaved = _started;
}
/**
......@@ -1675,6 +1678,10 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
if (nid.lastSeen() < expire)
iter.remove();
}
if (now - _nodesLastSaved > NODES_SAVE_TIME) {
PersistDHT.saveDHT(_knownNodes, false, _dhtFile);
_nodesLastSaved = now;
}
// TODO sent queries?
if (_log.shouldLog(Log.DEBUG))
_log.debug("KRPC cleaner done, now with " +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment