forked from I2P_Developers/i2p.i2p
- Thread magnet start if not connected
- Don't lose all DHT peers if we stop quickly - Explore a kbucket if it's less than 3/4 full - Change release torrent file names
This commit is contained in:
@ -518,6 +518,7 @@ public class KBucketSet<T extends SimpleDataStructure> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* For every bucket that hasn't been updated in this long,
|
* For every bucket that hasn't been updated in this long,
|
||||||
|
* or isn't close to full,
|
||||||
* generate a random key that would be a member of that bucket.
|
* generate a random key that would be a member of that bucket.
|
||||||
* The returned keys may be searched for to "refresh" the buckets.
|
* The returned keys may be searched for to "refresh" the buckets.
|
||||||
* @return non-null, closest first
|
* @return non-null, closest first
|
||||||
@ -528,7 +529,7 @@ public class KBucketSet<T extends SimpleDataStructure> {
|
|||||||
getReadLock();
|
getReadLock();
|
||||||
try {
|
try {
|
||||||
for (KBucket b : _buckets) {
|
for (KBucket b : _buckets) {
|
||||||
if (b.getLastChanged() < old)
|
if (b.getLastChanged() < old || b.getKeyCount() < BUCKET_SIZE * 3 / 4)
|
||||||
rv.add(generateRandomKey(b));
|
rv.add(generateRandomKey(b));
|
||||||
}
|
}
|
||||||
} finally { releaseReadLock(); }
|
} finally { releaseReadLock(); }
|
||||||
|
@ -959,7 +959,7 @@ public class SnarkManager implements CompleteListener {
|
|||||||
_snarks.put(name, torrent);
|
_snarks.put(name, torrent);
|
||||||
}
|
}
|
||||||
if (autoStart) {
|
if (autoStart) {
|
||||||
torrent.startTorrent();
|
startTorrent(ih);
|
||||||
addMessage(_("Fetching {0}", name));
|
addMessage(_("Fetching {0}", name));
|
||||||
DHT dht = _util.getDHT();
|
DHT dht = _util.getDHT();
|
||||||
boolean shouldWarn = _util.connected() &&
|
boolean shouldWarn = _util.connected() &&
|
||||||
|
@ -572,7 +572,9 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
|||||||
_session.removeListener(I2PSession.PROTO_DATAGRAM_RAW, _rPort);
|
_session.removeListener(I2PSession.PROTO_DATAGRAM_RAW, _rPort);
|
||||||
// clear the DHT and tracker
|
// clear the DHT and tracker
|
||||||
_tracker.stop();
|
_tracker.stop();
|
||||||
PersistDHT.saveDHT(_knownNodes, _dhtFile);
|
// don't lose all our peers if we didn't have time to check them
|
||||||
|
boolean saveAll = _context.clock().now() - _started < 20*60*1000;
|
||||||
|
PersistDHT.saveDHT(_knownNodes, saveAll, _dhtFile);
|
||||||
_knownNodes.stop();
|
_knownNodes.stop();
|
||||||
for (Iterator<ReplyWaiter> iter = _sentQueries.values().iterator(); iter.hasNext(); ) {
|
for (Iterator<ReplyWaiter> iter = _sentQueries.values().iterator(); iter.hasNext(); ) {
|
||||||
ReplyWaiter waiter = iter.next();
|
ReplyWaiter waiter = iter.next();
|
||||||
|
@ -56,12 +56,15 @@ abstract class PersistDHT {
|
|||||||
log.info("Loaded " + count + " nodes from " + file);
|
log.info("Loaded " + count + " nodes from " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void saveDHT(DHTNodes nodes, File file) {
|
/**
|
||||||
|
* @param saveAll if true, don't check last seen time
|
||||||
|
*/
|
||||||
|
public static synchronized void saveDHT(DHTNodes nodes, boolean saveAll, File file) {
|
||||||
if (nodes.size() <= 0)
|
if (nodes.size() <= 0)
|
||||||
return;
|
return;
|
||||||
Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
|
Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
long maxAge = I2PAppContext.getGlobalContext().clock().now() - MAX_AGE;
|
long maxAge = saveAll ? 0 : I2PAppContext.getGlobalContext().clock().now() - MAX_AGE;
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "ISO-8859-1")));
|
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "ISO-8859-1")));
|
||||||
|
@ -1554,7 +1554,7 @@
|
|||||||
<arg value="i2pupdate.sud" />
|
<arg value="i2pupdate.sud" />
|
||||||
</exec>
|
</exec>
|
||||||
<!-- make torrent files -->
|
<!-- make torrent files -->
|
||||||
<copy file="i2pupdate.sud" tofile="i2pupdate_${release.number}.sud" />
|
<copy file="i2pupdate.sud" tofile="i2pupdate-${release.number}.sud" />
|
||||||
<java classname="org.klomp.snark.Storage" fork="true" failonerror="true">
|
<java classname="org.klomp.snark.Storage" fork="true" failonerror="true">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="build/i2p.jar" />
|
<pathelement location="build/i2p.jar" />
|
||||||
@ -1562,7 +1562,7 @@
|
|||||||
</classpath>
|
</classpath>
|
||||||
<arg value="i2pupdate_${release.number}.sud" />
|
<arg value="i2pupdate_${release.number}.sud" />
|
||||||
</java>
|
</java>
|
||||||
<copy file="i2pupdate.su2" tofile="i2pupdate_${release.number}.su2" />
|
<copy file="i2pupdate.su2" tofile="i2pupdate-${release.number}.su2" />
|
||||||
<java classname="org.klomp.snark.Storage" fork="true" failonerror="true">
|
<java classname="org.klomp.snark.Storage" fork="true" failonerror="true">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="build/i2p.jar" />
|
<pathelement location="build/i2p.jar" />
|
||||||
|
Reference in New Issue
Block a user