* FloodfillMonitor:

- Fix ff count (we forgot ourselves)
       - Don't become ff if hidden
This commit is contained in:
zzz
2008-10-26 18:08:20 +00:00
parent 0c520de6e5
commit 2a08fc7a34
3 changed files with 13 additions and 6 deletions

View File

@ -54,6 +54,10 @@ class FloodfillMonitorJob extends JobImpl {
if (getContext().getProperty(Router.PROP_SHUTDOWN_IN_PROGRESS) != null)
return false;
// Hidden trumps netDb.floodfillParticipant=true
if (getContext().router().isHidden())
return false;
String enabled = getContext().getProperty(PROP_FLOODFILL_PARTICIPANT, "auto");
if ("true".equals(enabled))
return true;
@ -70,7 +74,7 @@ class FloodfillMonitorJob extends JobImpl {
if (getContext().router().getRouterInfo().getCapabilities().indexOf("O") < 0)
return false;
// This list may include ourselves...
// This list will not include ourselves...
List floodfillPeers = _facade.getFloodfillPeers();
long now = getContext().clock().now();
// We know none at all! Must be our turn...
@ -99,10 +103,8 @@ class FloodfillMonitorJob extends JobImpl {
int ffcount = floodfillPeers.size();
int failcount = 0;
long before = now - 60*60*1000;
for (int i = 0; i < floodfillPeers.size(); i++) {
for (int i = 0; i < ffcount; i++) {
Hash peer = (Hash)floodfillPeers.get(i);
if (peer.equals(getContext().routerHash()))
continue;
PeerProfile profile = getContext().profileOrganizer().getProfile(peer);
if (profile == null || profile.getLastHeardFrom() < before ||
profile.getIsFailing() || getContext().shitlist().isShitlisted(peer) ||
@ -110,6 +112,8 @@ class FloodfillMonitorJob extends JobImpl {
failcount++;
}
if (wasFF)
ffcount++;
int good = ffcount - failcount;
boolean happy = getContext().router().getRouterInfo().getCapabilities().indexOf("R") >= 0;
// Use the same job lag test as in RouterThrottleImpl

View File

@ -67,7 +67,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
*/
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException {
if (localRouterInfo == null) throw new IllegalArgumentException("wtf, null localRouterInfo?");
if (localRouterInfo.isHidden()) return; // DE-nied!
if (_context.router().isHidden()) return; // DE-nied!
super.publish(localRouterInfo);
sendStore(localRouterInfo.getIdentity().calculateHash(), localRouterInfo, null, null, PUBLISH_TIMEOUT, null);
}
@ -248,7 +248,9 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
synchronized (_activeFloodQueries) { _activeFloodQueries.remove(key); }
}
/** list of the Hashes of currently known floodfill peers */
/** list of the Hashes of currently known floodfill peers;
* Returned list will not include our own hash.
*/
public List getFloodfillPeers() {
FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
return sel.selectFloodfillParticipants(getKBuckets());

View File

@ -54,6 +54,7 @@ class FloodfillPeerSelector extends PeerSelector {
return rv;
}
/** Returned list will not include our own hash */
public List selectFloodfillParticipants(KBucketSet kbuckets) {
if (kbuckets == null) return new ArrayList();
FloodfillSelectionCollector matches = new FloodfillSelectionCollector(null, null, 0);