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:
@ -959,7 +959,7 @@ public class SnarkManager implements CompleteListener {
|
||||
_snarks.put(name, torrent);
|
||||
}
|
||||
if (autoStart) {
|
||||
torrent.startTorrent();
|
||||
startTorrent(ih);
|
||||
addMessage(_("Fetching {0}", name));
|
||||
DHT dht = _util.getDHT();
|
||||
boolean shouldWarn = _util.connected() &&
|
||||
|
@ -572,7 +572,9 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
|
||||
_session.removeListener(I2PSession.PROTO_DATAGRAM_RAW, _rPort);
|
||||
// clear the DHT and tracker
|
||||
_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();
|
||||
for (Iterator<ReplyWaiter> iter = _sentQueries.values().iterator(); iter.hasNext(); ) {
|
||||
ReplyWaiter waiter = iter.next();
|
||||
|
@ -56,12 +56,15 @@ abstract class PersistDHT {
|
||||
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)
|
||||
return;
|
||||
Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
|
||||
int count = 0;
|
||||
long maxAge = I2PAppContext.getGlobalContext().clock().now() - MAX_AGE;
|
||||
long maxAge = saveAll ? 0 : I2PAppContext.getGlobalContext().clock().now() - MAX_AGE;
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "ISO-8859-1")));
|
||||
|
Reference in New Issue
Block a user