- 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:
zzz
2012-10-23 19:34:35 +00:00
parent bb2363f68a
commit 2f69d16828
5 changed files with 13 additions and 7 deletions

View File

@ -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() &&

View File

@ -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();

View File

@ -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")));