PeerManager API cleanup (ticket #2456)

This commit is contained in:
zzz
2019-04-18 12:46:51 +00:00
parent 67570db664
commit a8ad30b335
6 changed files with 11 additions and 24 deletions

View File

@ -20,13 +20,6 @@ import net.i2p.data.Hash;
*
*/
public interface PeerManagerFacade extends Service {
/**
* Select peers from the manager's existing routing tables according to
* the specified criteria. This call DOES block.
*
* @return List of Hash objects of the RouterIdentity for matching peers
*/
public List<Hash> selectPeers(PeerSelectionCriteria criteria);
public Set<Hash> getPeersByCapability(char capability);
public void setCapabilities(Hash peer, String caps);
public void removeCapabilities(Hash peer);

View File

@ -14,7 +14,6 @@ import java.util.Set;
import net.i2p.data.Hash;
import net.i2p.router.PeerManagerFacade;
import net.i2p.router.PeerSelectionCriteria;
/**
* Manage peer references and keep them up to date so that when asked for peers,
@ -27,7 +26,6 @@ public class DummyPeerManagerFacade implements PeerManagerFacade {
public void startup() {}
public void restart() {}
public void renderStatusHTML(Writer out) { }
public List<Hash> selectPeers(PeerSelectionCriteria criteria) { return null; }
public Set<Hash> getPeersByCapability(char capability) { return null; }
public void setCapabilities(Hash peer, String caps) {}
public void removeCapabilities(Hash peer) {}

View File

@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import net.i2p.data.Hash;
import net.i2p.data.router.RouterInfo;
import net.i2p.router.PeerSelectionCriteria;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
@ -245,6 +244,7 @@ class PeerManager {
//_organizer.selectNotFailingPeers(criteria.getMinimumRequired(), exclude, peers);
_organizer.selectActiveNotFailingPeers(criteria.getMinimumRequired(), exclude, peers);
break;
/****
case PeerSelectionCriteria.PURPOSE_TUNNEL:
// pull all of the fast ones, regardless of how many we
// want - we'll whittle them down later (40 lines from now)
@ -260,8 +260,9 @@ class PeerManager {
case PeerSelectionCriteria.PURPOSE_GARLIC:
_organizer.selectHighCapacityPeers(criteria.getMinimumRequired(), exclude, peers);
break;
****/
default:
break;
throw new UnsupportedOperationException();
}
if (peers.isEmpty()) {
if (_log.shouldLog(Log.WARN))

View File

@ -16,7 +16,6 @@ import java.util.Set;
import net.i2p.data.Hash;
import net.i2p.router.PeerManagerFacade;
import net.i2p.router.PeerSelectionCriteria;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
@ -60,10 +59,6 @@ public class PeerManagerFacadeImpl implements PeerManagerFacade {
_manager.loadProfiles();
}
public List<Hash> selectPeers(PeerSelectionCriteria criteria) {
return _manager.selectPeers(criteria);
}
/**
* @param caps non-null
*/

View File

@ -1,4 +1,4 @@
package net.i2p.router;
package net.i2p.router.peermanager;
/*
* free (adj.): unencumbered; not under the control of others
* Written by jrandom in 2003 and released into the public domain
@ -13,14 +13,16 @@ package net.i2p.router;
* PeerManager
*
* Only used by PeerTestJob, which may not have a point.
*
* @since moved from router to peermanager in 0.9.40
*/
public class PeerSelectionCriteria {
class PeerSelectionCriteria {
/** The peers will be used in a tunnel */
public final static int PURPOSE_TUNNEL = 1;
//public final static int PURPOSE_TUNNEL = 1;
/** The peers will be used for garlic routed messages */
public final static int PURPOSE_GARLIC = 2;
//public final static int PURPOSE_GARLIC = 2;
/** The peers will be used for a source routed reply block message */
public final static int PURPOSE_SOURCE_ROUTE = 3;
//public final static int PURPOSE_SOURCE_ROUTE = 3;
/** The peers will be used for a test message */
public final static int PURPOSE_TEST = 4;

View File

@ -12,7 +12,6 @@ import net.i2p.data.i2np.DeliveryStatusMessage;
import net.i2p.data.i2np.I2NPMessage;
import net.i2p.router.JobImpl;
import net.i2p.router.MessageSelector;
import net.i2p.router.PeerSelectionCriteria;
import net.i2p.router.ReplyJob;
import net.i2p.router.RouterContext;
import net.i2p.router.TunnelInfo;
@ -27,7 +26,7 @@ import net.i2p.util.Log;
* TODO - What's the point? Disable this? See also notes in PeerManager.selectPeers().
* TODO - Use something besides sending the peer's RI to itself?
*/
public class PeerTestJob extends JobImpl {
class PeerTestJob extends JobImpl {
private final Log _log;
private PeerManager _manager;
private boolean _keepTesting;
@ -49,7 +48,6 @@ public class PeerTestJob extends JobImpl {
/** number of peers to test each round */
private int getTestConcurrency() { return 1; }
// FIXME Exporting non-public type through public API FIXME
public synchronized void startTesting(PeerManager manager) {
_manager = manager;
_keepTesting = true;