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

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

merge of '186e5e48c613c85b8e11c61ec920a40837bfae8e'

     and '3449c389b42e40b9c9a07848a868bb745c5c4540'
parents ec4c830c 6c32a053
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
/** signed dgrams */
private final int _qPort;
private final File _dhtFile;
private final File _backupDhtFile;
private volatile boolean _isRunning;
private volatile boolean _hasBootstrapped;
/** stats */
......@@ -160,7 +161,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
/**
* @param baseName generally "i2psnark"
*/
public KRPC (I2PAppContext ctx, String baseName, I2PSession session) {
public KRPC(I2PAppContext ctx, String baseName, I2PSession session) {
_context = ctx;
_session = session;
_log = ctx.logManager().getLog(KRPC.class);
......@@ -186,6 +187,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
}
_myNodeInfo = new NodeInfo(_myNID, session.getMyDestination(), _qPort);
_dhtFile = new File(ctx.getConfigDir(), baseName + DHT_FILE_SUFFIX);
_backupDhtFile = baseName.equals("i2psnark") ? null : new File(ctx.getConfigDir(), "i2psnark" + DHT_FILE_SUFFIX);
_knownNodes = new DHTNodes(ctx, _myNID);
start();
......@@ -550,7 +552,7 @@ public class KRPC implements I2PSessionMuxedListener, DHT {
_session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM, _qPort);
_knownNodes.start();
_tracker.start();
PersistDHT.loadDHT(this, _dhtFile);
PersistDHT.loadDHT(this, _dhtFile, _backupDhtFile);
// start the explore thread
_isRunning = true;
// no need to keep ref, it will eventually stop
......
......@@ -23,6 +23,17 @@ abstract class PersistDHT {
private static final long MAX_AGE = 60*60*1000;
/**
* @param backupFile may be null
* @since 0.9.6
*/
public static synchronized void loadDHT(KRPC krpc, File file, File backupFile) {
if (file.exists())
loadDHT(krpc, file);
else if (backupFile != null)
loadDHT(krpc, backupFile);
}
public static synchronized void loadDHT(KRPC krpc, File file) {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(PersistDHT.class);
int count = 0;
......@@ -57,7 +68,6 @@ abstract class PersistDHT {
}
/**
* TODO - multiple instances overwrite each other
* @param saveAll if true, don't check last seen time
*/
public static synchronized void saveDHT(DHTNodes nodes, boolean saveAll, File file) {
......
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