* FloodfillMonitor:
- Fix ff count (we forgot ourselves) - Don't become ff if hidden
This commit is contained in:
@ -54,6 +54,10 @@ class FloodfillMonitorJob extends JobImpl {
|
|||||||
if (getContext().getProperty(Router.PROP_SHUTDOWN_IN_PROGRESS) != null)
|
if (getContext().getProperty(Router.PROP_SHUTDOWN_IN_PROGRESS) != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Hidden trumps netDb.floodfillParticipant=true
|
||||||
|
if (getContext().router().isHidden())
|
||||||
|
return false;
|
||||||
|
|
||||||
String enabled = getContext().getProperty(PROP_FLOODFILL_PARTICIPANT, "auto");
|
String enabled = getContext().getProperty(PROP_FLOODFILL_PARTICIPANT, "auto");
|
||||||
if ("true".equals(enabled))
|
if ("true".equals(enabled))
|
||||||
return true;
|
return true;
|
||||||
@ -70,7 +74,7 @@ class FloodfillMonitorJob extends JobImpl {
|
|||||||
if (getContext().router().getRouterInfo().getCapabilities().indexOf("O") < 0)
|
if (getContext().router().getRouterInfo().getCapabilities().indexOf("O") < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// This list may include ourselves...
|
// This list will not include ourselves...
|
||||||
List floodfillPeers = _facade.getFloodfillPeers();
|
List floodfillPeers = _facade.getFloodfillPeers();
|
||||||
long now = getContext().clock().now();
|
long now = getContext().clock().now();
|
||||||
// We know none at all! Must be our turn...
|
// We know none at all! Must be our turn...
|
||||||
@ -99,10 +103,8 @@ class FloodfillMonitorJob extends JobImpl {
|
|||||||
int ffcount = floodfillPeers.size();
|
int ffcount = floodfillPeers.size();
|
||||||
int failcount = 0;
|
int failcount = 0;
|
||||||
long before = now - 60*60*1000;
|
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);
|
Hash peer = (Hash)floodfillPeers.get(i);
|
||||||
if (peer.equals(getContext().routerHash()))
|
|
||||||
continue;
|
|
||||||
PeerProfile profile = getContext().profileOrganizer().getProfile(peer);
|
PeerProfile profile = getContext().profileOrganizer().getProfile(peer);
|
||||||
if (profile == null || profile.getLastHeardFrom() < before ||
|
if (profile == null || profile.getLastHeardFrom() < before ||
|
||||||
profile.getIsFailing() || getContext().shitlist().isShitlisted(peer) ||
|
profile.getIsFailing() || getContext().shitlist().isShitlisted(peer) ||
|
||||||
@ -110,6 +112,8 @@ class FloodfillMonitorJob extends JobImpl {
|
|||||||
failcount++;
|
failcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wasFF)
|
||||||
|
ffcount++;
|
||||||
int good = ffcount - failcount;
|
int good = ffcount - failcount;
|
||||||
boolean happy = getContext().router().getRouterInfo().getCapabilities().indexOf("R") >= 0;
|
boolean happy = getContext().router().getRouterInfo().getCapabilities().indexOf("R") >= 0;
|
||||||
// Use the same job lag test as in RouterThrottleImpl
|
// Use the same job lag test as in RouterThrottleImpl
|
||||||
|
@ -67,7 +67,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
|
|||||||
*/
|
*/
|
||||||
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException {
|
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException {
|
||||||
if (localRouterInfo == null) throw new IllegalArgumentException("wtf, null localRouterInfo?");
|
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);
|
super.publish(localRouterInfo);
|
||||||
sendStore(localRouterInfo.getIdentity().calculateHash(), localRouterInfo, null, null, PUBLISH_TIMEOUT, null);
|
sendStore(localRouterInfo.getIdentity().calculateHash(), localRouterInfo, null, null, PUBLISH_TIMEOUT, null);
|
||||||
}
|
}
|
||||||
@ -248,7 +248,9 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
|
|||||||
synchronized (_activeFloodQueries) { _activeFloodQueries.remove(key); }
|
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() {
|
public List getFloodfillPeers() {
|
||||||
FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
|
FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
|
||||||
return sel.selectFloodfillParticipants(getKBuckets());
|
return sel.selectFloodfillParticipants(getKBuckets());
|
||||||
|
@ -54,6 +54,7 @@ class FloodfillPeerSelector extends PeerSelector {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returned list will not include our own hash */
|
||||||
public List selectFloodfillParticipants(KBucketSet kbuckets) {
|
public List selectFloodfillParticipants(KBucketSet kbuckets) {
|
||||||
if (kbuckets == null) return new ArrayList();
|
if (kbuckets == null) return new ArrayList();
|
||||||
FloodfillSelectionCollector matches = new FloodfillSelectionCollector(null, null, 0);
|
FloodfillSelectionCollector matches = new FloodfillSelectionCollector(null, null, 0);
|
||||||
|
Reference in New Issue
Block a user