forked from I2P_Developers/i2p.i2p
* NetDB: Hopefully fix rare NPE (ticket #589)
This commit is contained in:
@ -25,10 +25,10 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class KBucketSet {
|
class KBucketSet {
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private LocalHash _us;
|
private final LocalHash _us;
|
||||||
private KBucket _buckets[];
|
private final KBucket _buckets[];
|
||||||
private volatile int _size;
|
private volatile int _size;
|
||||||
|
|
||||||
public final static int BASE = 8; // must go into KEYSIZE_BITS evenly
|
public final static int BASE = 8; // must go into KEYSIZE_BITS evenly
|
||||||
@ -41,7 +41,7 @@ class KBucketSet {
|
|||||||
_us = new LocalHash(us);
|
_us = new LocalHash(us);
|
||||||
_context = context;
|
_context = context;
|
||||||
_log = context.logManager().getLog(KBucketSet.class);
|
_log = context.logManager().getLog(KBucketSet.class);
|
||||||
createBuckets();
|
_buckets = createBuckets();
|
||||||
context.statManager().createRateStat("netDb.KBSGetAllTime", "Time to add all Hashes to the Collector", "NetworkDatabase", new long[] { 60*60*1000 });
|
context.statManager().createRateStat("netDb.KBSGetAllTime", "Time to add all Hashes to the Collector", "NetworkDatabase", new long[] { 60*60*1000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,12 +132,13 @@ class KBucketSet {
|
|||||||
|
|
||||||
public KBucket getBucket(int bucket) { return _buckets[bucket]; }
|
public KBucket getBucket(int bucket) { return _buckets[bucket]; }
|
||||||
|
|
||||||
protected void createBuckets() {
|
protected KBucket[] createBuckets() {
|
||||||
_buckets = new KBucket[NUM_BUCKETS];
|
KBucket[] buckets = new KBucket[NUM_BUCKETS];
|
||||||
for (int i = 0; i < NUM_BUCKETS-1; i++) {
|
for (int i = 0; i < NUM_BUCKETS-1; i++) {
|
||||||
_buckets[i] = createBucket(i*BASE, (i+1)*BASE);
|
buckets[i] = createBucket(i*BASE, (i+1)*BASE);
|
||||||
}
|
}
|
||||||
_buckets[NUM_BUCKETS-1] = createBucket(BASE*(NUM_BUCKETS-1), BASE*(NUM_BUCKETS) + 1);
|
buckets[NUM_BUCKETS-1] = createBucket(BASE*(NUM_BUCKETS-1), BASE*(NUM_BUCKETS) + 1);
|
||||||
|
return buckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KBucket createBucket(int start, int end) {
|
protected KBucket createBucket(int start, int end) {
|
||||||
|
Reference in New Issue
Block a user