forked from I2P_Developers/i2p.i2p
* i2psnark:
- Adjust DHT timeouts - Add max peers per-torrent in tracker - Remove duplicate clean task for nodes - Fix another DHT warning message
This commit is contained in:
@ -38,11 +38,12 @@ class DHTNodes {
|
||||
private volatile boolean _isRunning;
|
||||
|
||||
/** stagger with other cleaners */
|
||||
private static final long CLEAN_TIME = 237*1000;
|
||||
private static final long MAX_EXPIRE_TIME = 60*60*1000;
|
||||
private static final long MIN_EXPIRE_TIME = 5*60*1000;
|
||||
private static final long DELTA_EXPIRE_TIME = 7*60*1000;
|
||||
private static final int MAX_PEERS = 999;
|
||||
private static final long CLEAN_TIME = 187*1000;
|
||||
/** how long since last heard from do we delete - BEP 5 says 15 minutes */
|
||||
private static final long MAX_EXPIRE_TIME = 30*60*1000;
|
||||
private static final long MIN_EXPIRE_TIME = 10*60*1000;
|
||||
private static final long DELTA_EXPIRE_TIME = 3*60*1000;
|
||||
private static final int MAX_PEERS = 799;
|
||||
|
||||
public DHTNodes(I2PAppContext ctx, NID me) {
|
||||
_context = ctx;
|
||||
|
@ -34,11 +34,11 @@ class DHTTracker {
|
||||
|
||||
/** stagger with other cleaners */
|
||||
private static final long CLEAN_TIME = 199*1000;
|
||||
/** make this longer than postman's tracker */
|
||||
private static final long MAX_EXPIRE_TIME = 95*60*1000;
|
||||
private static final long MIN_EXPIRE_TIME = 5*60*1000;
|
||||
private static final long DELTA_EXPIRE_TIME = 7*60*1000;
|
||||
private static final long MAX_EXPIRE_TIME = 45*60*1000;
|
||||
private static final long MIN_EXPIRE_TIME = 15*60*1000;
|
||||
private static final long DELTA_EXPIRE_TIME = 3*60*1000;
|
||||
private static final int MAX_PEERS = 2000;
|
||||
private static final int MAX_PEERS_PER_TORRENT = 150;
|
||||
|
||||
DHTTracker(I2PAppContext ctx) {
|
||||
_context = ctx;
|
||||
@ -134,10 +134,20 @@ class DHTTracker {
|
||||
peerCount++;
|
||||
}
|
||||
}
|
||||
if (recent <= 0)
|
||||
iter.remove();
|
||||
else
|
||||
if (recent > MAX_PEERS_PER_TORRENT) {
|
||||
// too many, delete at random
|
||||
// TODO per-torrent adjustable expiration?
|
||||
for (Iterator<Peer> iterp = p.values().iterator(); iterp.hasNext() && p.size() > MAX_PEERS_PER_TORRENT; ) {
|
||||
iterp.next();
|
||||
iterp.remove();
|
||||
peerCount--;
|
||||
}
|
||||
torrentCount++;
|
||||
} else if (recent <= 0) {
|
||||
iter.remove();
|
||||
} else {
|
||||
torrentCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (peerCount > MAX_PEERS)
|
||||
|
@ -135,10 +135,8 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
||||
|
||||
public static final boolean SECURE_NID = true;
|
||||
|
||||
/** how long since last heard from do we delete - BEP 5 says 15 minutes */
|
||||
private static final long MAX_NODEINFO_AGE = 60*60*1000;
|
||||
/** how long since generated do we delete - BEP 5 says 10 minutes */
|
||||
private static final long MAX_TOKEN_AGE = 60*60*1000;
|
||||
private static final long MAX_TOKEN_AGE = 15*60*1000;
|
||||
private static final long MAX_INBOUND_TOKEN_AGE = MAX_TOKEN_AGE - 5*60*1000;
|
||||
/** how long since sent do we wait for a reply */
|
||||
private static final long MAX_MSGID_AGE = 2*60*1000;
|
||||
@ -1469,11 +1467,6 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
||||
iter.remove();
|
||||
}
|
||||
// TODO sent queries?
|
||||
for (Iterator<NodeInfo> iter = _knownNodes.values().iterator(); iter.hasNext(); ) {
|
||||
NodeInfo ni = iter.next();
|
||||
if (ni.lastSeen() < now - MAX_NODEINFO_AGE)
|
||||
iter.remove();
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("KRPC cleaner done, now with " +
|
||||
_outgoingTokens.size() + " sent Tokens, " +
|
||||
|
@ -16,6 +16,6 @@ import net.i2p.data.Hash;
|
||||
class Peers extends ConcurrentHashMap<Hash, Peer> {
|
||||
|
||||
public Peers() {
|
||||
super();
|
||||
super(8);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user