fix geoip scan of all routerinfos at startup
This commit is contained in:
@ -58,6 +58,7 @@ class DummyNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
_routers.remove(dbEntry);
|
||||
}
|
||||
|
||||
public Set<Hash> getAllRouters() { return new HashSet(_routers.keySet()); }
|
||||
public Set findNearestRouters(Hash key, int maxNumRouters, Set peersToIgnore) { return new HashSet(_routers.values()); }
|
||||
|
||||
public void renderStatusHTML(Writer out) throws IOException {}
|
||||
|
@ -55,6 +55,7 @@ public abstract class NetworkDatabaseFacade implements Service {
|
||||
public abstract void unpublish(LeaseSet localLeaseSet);
|
||||
public abstract void fail(Hash dbEntry);
|
||||
|
||||
public abstract Set<Hash> getAllRouters();
|
||||
public int getKnownRouters() { return 0; }
|
||||
public int getKnownLeaseSets() { return 0; }
|
||||
public void renderRouterInfoHTML(Writer out, String s) throws IOException {}
|
||||
|
@ -311,7 +311,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
|
||||
/** get the hashes for all known routers */
|
||||
Set getAllRouters() {
|
||||
public Set<Hash> getAllRouters() {
|
||||
if (!_initialized) return new HashSet(0);
|
||||
Set keys = _ds.getKeys();
|
||||
Set rv = new HashSet(keys.size());
|
||||
|
@ -375,15 +375,13 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
/**
|
||||
* Collect the IPs for all routers in the DB, and queue them for lookup,
|
||||
* then fire off the periodic lookup task for the first time.
|
||||
*
|
||||
* We could use getAllRouters() if it were public, and that would be faster, but
|
||||
* we only do this once.
|
||||
*/
|
||||
private class QueueAll implements SimpleTimer.TimedEvent {
|
||||
public void timeReached() {
|
||||
Set routers = _context.netDb().findNearestRouters(_context.routerHash(), _context.netDb().getKnownRouters(), null);
|
||||
for (Iterator iter = routers.iterator(); iter.hasNext(); ) {
|
||||
RouterInfo ri = (RouterInfo) iter.next();
|
||||
for (Iterator<Hash> iter = _context.netDb().getAllRouters().iterator(); iter.hasNext(); ) {
|
||||
RouterInfo ri = _context.netDb().lookupRouterInfoLocally(iter.next());
|
||||
if (ri == null)
|
||||
continue;
|
||||
String host = getIPString(ri);
|
||||
if (host == null)
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user