cleanup the shitlist code
logging
This commit is contained in:
@ -124,7 +124,11 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
|||||||
boolean isShitlisted(Hash key) {
|
boolean isShitlisted(Hash key) {
|
||||||
synchronized (_badKeys) {
|
synchronized (_badKeys) {
|
||||||
locked_cleanupShitlist();
|
locked_cleanupShitlist();
|
||||||
return !_badKeys.contains(key);
|
boolean isShitlisted = _badKeys.contains(key);
|
||||||
|
if (!isShitlisted) return false;
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("Key " + key.toBase64() + " is shitlisted");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -136,11 +140,16 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
|||||||
void shitlist(Hash key) {
|
void shitlist(Hash key) {
|
||||||
synchronized (_badKeys) {
|
synchronized (_badKeys) {
|
||||||
locked_cleanupShitlist();
|
locked_cleanupShitlist();
|
||||||
_badKeys.add(key);
|
boolean wasNew = _badKeys.add(key);
|
||||||
long when = _context.clock().now();
|
if (wasNew) {
|
||||||
while (_badKeyDates.containsKey(new Long(when)))
|
long when = _context.clock().now();
|
||||||
when++;
|
while (_badKeyDates.containsKey(new Long(when)))
|
||||||
_badKeyDates.put(new Long(when), key);
|
when++;
|
||||||
|
_badKeyDates.put(new Long(when), key);
|
||||||
|
_log.info("Shitlist " + key.toBase64() + " - new shitlist");
|
||||||
|
} else {
|
||||||
|
_log.info("Shitlist " + key.toBase64() + " - already shitlisted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void locked_cleanupShitlist() {
|
private void locked_cleanupShitlist() {
|
||||||
@ -166,11 +175,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_badKeys.size() > 0) {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Cleaning up shitlist: " + _badKeys.size() + " remain after removing "
|
_log.debug("Cleaning up shitlist: " + _badKeys.size() + " remain after removing "
|
||||||
+ (old != null ? old.size() : 0));
|
+ (old != null ? old.size() : 0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KBucketSet getKBuckets() { return _kb; }
|
KBucketSet getKBuckets() { return _kb; }
|
||||||
|
Reference in New Issue
Block a user