Changeset 6c32a05


Ignore:
Timestamp:
Apr 15, 2013 8:56:10 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e34a9862
Parents:
9e5d809
Message:

2nd instance bootstraps DHT from 1st instance

Location:
apps/i2psnark/java/src/org/klomp/snark/dht
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/dht/KRPC.java

    r9e5d809 r6c32a05  
    115115    private final int _qPort;
    116116    private final File _dhtFile;
     117    private final File _backupDhtFile;
    117118    private volatile boolean _isRunning;
    118119    private volatile boolean _hasBootstrapped;
     
    161162     *  @param baseName generally "i2psnark"
    162163     */
    163     public KRPC (I2PAppContext ctx, String baseName, I2PSession session) {
     164    public KRPC(I2PAppContext ctx, String baseName, I2PSession session) {
    164165        _context = ctx;
    165166        _session = session;
     
    187188        _myNodeInfo = new NodeInfo(_myNID, session.getMyDestination(), _qPort);
    188189        _dhtFile = new File(ctx.getConfigDir(), baseName + DHT_FILE_SUFFIX);
     190        _backupDhtFile = baseName.equals("i2psnark") ? null : new File(ctx.getConfigDir(), "i2psnark" + DHT_FILE_SUFFIX);
    189191        _knownNodes = new DHTNodes(ctx, _myNID);
    190192
     
    551553        _knownNodes.start();
    552554        _tracker.start();
    553         PersistDHT.loadDHT(this, _dhtFile);
     555        PersistDHT.loadDHT(this, _dhtFile, _backupDhtFile);
    554556        // start the explore thread
    555557        _isRunning = true;
  • apps/i2psnark/java/src/org/klomp/snark/dht/PersistDHT.java

    r9e5d809 r6c32a05  
    2323
    2424    private static final long MAX_AGE = 60*60*1000;
     25
     26    /**
     27     *  @param backupFile may be null
     28     *  @since 0.9.6
     29     */
     30    public static synchronized void loadDHT(KRPC krpc, File file, File backupFile) {
     31        if (file.exists())
     32            loadDHT(krpc, file);
     33        else if (backupFile != null)
     34            loadDHT(krpc, backupFile);
     35    }
    2536
    2637    public static synchronized void loadDHT(KRPC krpc, File file) {
     
    5869
    5970    /**
    60      *  TODO - multiple instances overwrite each other
    6171     *  @param saveAll if true, don't check last seen time
    6272     */
Note: See TracChangeset for help on using the changeset viewer.