forked from I2P_Developers/i2p.i2p
NetDB:
- Increase new kad size to K=24, B=4 - Fix router count by counting in the data store, not the kbuckets - Randomize the order we load router infos at startup so we don't bias the kbuckets
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2013-12-13 zzz
|
||||
* i2ptunnel: Show destination for persistent client key only if available;
|
||||
show b32 for the key as well
|
||||
* NetDB:
|
||||
- Increase new kad size to K=24, B=4
|
||||
- Fix router count by counting in the data store, not the kbuckets
|
||||
- Randomize the order we load router infos at startup so we
|
||||
don't bias the kbuckets
|
||||
|
||||
2013-12-10 zzz
|
||||
Prop from i2p.i2p.zzz.test2:
|
||||
* Config files: Allow empty values
|
||||
|
||||
@@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 1;
|
||||
public final static long BUILD = 2;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
||||
@@ -143,8 +143,8 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
* kad K
|
||||
* Was 500 in old implementation but that was with B ~= -8!
|
||||
*/
|
||||
private static final int BUCKET_SIZE = 16;
|
||||
private static final int KAD_B = 3;
|
||||
private static final int BUCKET_SIZE = 24;
|
||||
private static final int KAD_B = 4;
|
||||
|
||||
public KademliaNetworkDatabaseFacade(RouterContext context) {
|
||||
_context = context;
|
||||
@@ -373,14 +373,30 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* This used to return the number of routers that were in
|
||||
* both the kbuckets AND the data store, which was fine when the kbuckets held everything.
|
||||
* But now that is probably not what you want.
|
||||
* Just return the count in the data store.
|
||||
*/
|
||||
@Override
|
||||
public int getKnownRouters() {
|
||||
/****
|
||||
if (_kb == null) return 0;
|
||||
CountRouters count = new CountRouters();
|
||||
_kb.getAll(count);
|
||||
return count.size();
|
||||
****/
|
||||
if (_ds == null) return 0;
|
||||
int rv = 0;
|
||||
for (DatabaseEntry ds : _ds.getEntries()) {
|
||||
if (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO)
|
||||
rv++;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/****
|
||||
private class CountRouters implements SelectionCollector<Hash> {
|
||||
private int _count;
|
||||
public int size() { return _count; }
|
||||
@@ -391,6 +407,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
****/
|
||||
|
||||
/**
|
||||
* This is only used by StatisticsManager to publish
|
||||
@@ -416,6 +433,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
* This is fast and doesn't use synchronization,
|
||||
* but it includes both routerinfos and leasesets.
|
||||
* Use it to avoid deadlocks.
|
||||
* No - not true - the KBS contains RIs only.
|
||||
*/
|
||||
protected int getKBucketSetSize() {
|
||||
if (_kb == null) return 0;
|
||||
|
||||
@@ -16,7 +16,10 @@ import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -398,6 +401,10 @@ class PersistentDataStore extends TransientDataStore {
|
||||
// move all new RIs to subdirs, then scan those
|
||||
if (routerInfoFiles != null)
|
||||
migrate(_dbDir, routerInfoFiles);
|
||||
// Loading the files in-order causes clumping in the kbuckets,
|
||||
// and bias on early peer selection, so first collect all the files,
|
||||
// then shuffle and load.
|
||||
List<File> toRead = new ArrayList<File>(2048);
|
||||
for (int j = 0; j < B64.length(); j++) {
|
||||
File subdir = new File(_dbDir, DIR_PREFIX + B64.charAt(j));
|
||||
File[] files = subdir.listFiles(RouterInfoFilter.getInstance());
|
||||
@@ -410,11 +417,15 @@ class PersistentDataStore extends TransientDataStore {
|
||||
if (lastMod <= _lastModified)
|
||||
continue;
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
Hash key = getRouterInfoHash(files[i].getName());
|
||||
if (key != null && !isKnown(key))
|
||||
(new ReadRouterJob(files[i], key)).runJob();
|
||||
toRead.add(files[i]);
|
||||
}
|
||||
}
|
||||
Collections.shuffle(toRead, _context.random());
|
||||
for (File file : toRead) {
|
||||
Hash key = getRouterInfoHash(file.getName());
|
||||
if (key != null && !isKnown(key))
|
||||
(new ReadRouterJob(file, key)).runJob();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_initialized) {
|
||||
|
||||
Reference in New Issue
Block a user