Skip to content

Commit

Permalink
Router: FNDS javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedeekay committed Sep 18, 2023
1 parent f1187bd commit 03a131c
Showing 1 changed file with 121 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,27 @@ public FloodfillNetworkDatabaseSegmentor(RouterContext context) {
_exploratoryDbid = new FloodfillNetworkDatabaseFacade(_context, EXPLORATORY_DBID);
}

/**
* Retrieves the FloodfillNetworkDatabaseFacade object for the specified ID.
* If the ID is null, the main database is returned.
*
* @param id the ID of the FloodfillNetworkDatabaseFacade object to retrieve
* @return the FloodfillNetworkDatabaseFacade object corresponding to the ID
*/
@Override
public FloodfillNetworkDatabaseFacade getSubNetDB(Hash id) {
if (id == null)
return getSubNetDB(MAIN_DBID);
return getSubNetDB(id.toBase32());
}

/**
* Retrieves the FloodfillNetworkDatabaseFacade object for the specified ID string.
*
* @param id the ID of the FloodfillNetworkDatabaseFacade object to retrieve
* @return the FloodfillNetworkDatabaseFacade object for the specified ID
*
*/
@Override
protected FloodfillNetworkDatabaseFacade getSubNetDB(String id) {
if (id == null || id.isEmpty() || id.equals(MAIN_DBID))
Expand All @@ -119,8 +133,10 @@ protected FloodfillNetworkDatabaseFacade getSubNetDB(String id) {

/**
* If we are floodfill, turn it off and tell everybody.
* Shut down all known subDbs.
*
* @since 0.9.60
*
* @since 0.8.9
*/
public synchronized void shutdown() {
// shut down every entry in _subDBs
Expand All @@ -133,12 +149,18 @@ public synchronized void shutdown() {
}
}

/**
* list of the RouterInfo objects for all known peers;
*
* @since 0.9.60
*
*/
public List<RouterInfo> getKnownRouterData() {
List<RouterInfo> rv = new ArrayList<RouterInfo>();
for (FloodfillNetworkDatabaseFacade subdb : getSubNetDBs()) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("(dbid: " + subdb._dbid
+ ") Deprecated! Arbitrary selection of this subDb",
+ ") Called from FNDS, will be combined with all other subDbs",
new Exception());
rv.addAll(subdb.getKnownRouterData());
}
Expand All @@ -149,6 +171,8 @@ public List<RouterInfo> getKnownRouterData() {
* list of the Hashes of currently known floodfill peers;
* Returned list will not include our own hash.
* List is not sorted and not shuffled.
*
* @since 0.9.60
*/
public List<Hash> getFloodfillPeers() {
List<Hash> peers = new ArrayList<Hash>();
Expand All @@ -175,6 +199,14 @@ public LeaseSet lookupLeaseSetHashIsClient(Hash key) {
return lookupLeaseSetLocally(key, dbid);
}

/**
* Lookup using the client's tunnels when the client LS key is known.
* if a DBID is not provided, the clients will all be checked, and the
* first value will be used.
*
* @since 0.9.60
*
*/
@Override
protected LeaseSet lookupLeaseSetLocally(Hash key, String dbid) {
if (dbid == null || dbid.isEmpty()) {
Expand All @@ -197,8 +229,14 @@ protected LeaseSet lookupLeaseSetLocally(Hash key, String dbid) {
return this.getSubNetDB(dbid).lookupLeaseSetLocally(key);
}

/**
* Check if all of the known subDbs are initialized
*
* @since 0.9.60
*
*/
public boolean isInitialized() {
boolean rv = false;
boolean rv = mainNetDB().isInitialized();
for (FloodfillNetworkDatabaseFacade subdb : getSubNetDBs()) {
rv = subdb.isInitialized();
if (!rv) {
Expand All @@ -208,6 +246,12 @@ public boolean isInitialized() {
return rv;
}

/**
* list of the RouterInfo objects for all known peers
*
* @since 0.9.60
*
*/
@Override
public Set<RouterInfo> getRouters() {
Set<RouterInfo> rv = new HashSet<>();
Expand All @@ -221,6 +265,14 @@ public Set<RouterInfo> getRouters() {
return rv;
}



/**
* list of the RouterInfo objects for all known peers known to clients(in subDbs) only
*
* @since 0.9.60
*
*/
public Set<RouterInfo> getRoutersKnownToClients() {
Set<RouterInfo> rv = new HashSet<>();
for (String key : getClients()) {
Expand All @@ -229,6 +281,12 @@ public Set<RouterInfo> getRoutersKnownToClients() {
return rv;
}

/**
* list of the LeaseSet objects for all known peers known to clients(in subDbs) only
*
* @since 0.9.60
*
*/
public Set<LeaseSet> getLeasesKnownToClients() {
Set<LeaseSet> rv = new HashSet<>();
for (String key : getClients()) {
Expand All @@ -237,6 +295,12 @@ public Set<LeaseSet> getLeasesKnownToClients() {
return rv;
}

/**
* list all of the dbids of all known client subDbs
*
* @since 0.9.60
*
*/
public List<String> getClients() {
List<String> rv = new ArrayList<String>();
for (String key : _subDBs.keySet()) {
Expand All @@ -248,39 +312,81 @@ public List<String> getClients() {
return rv;
}

/**
* get the main netDb, which is the one we will use if we are a floodfill
*
* @since 0.9.60
*
*/
@Override
public FloodfillNetworkDatabaseFacade mainNetDB() {
return _mainDbid;
}

/**
* get the multiHome netDb, which is especially for handling multihomes
*
* @since 0.9.60
*
*/
@Override
public FloodfillNetworkDatabaseFacade multiHomeNetDB() {
return _multihomeDbid;
}

/**
* get the client netDb for the given id
*
* @since 0.9.60
*
*/
@Override
public FloodfillNetworkDatabaseFacade clientNetDB(String id) {
if (id == null || id.isEmpty())
return exploratoryNetDB();
return this.getSubNetDB(id);
}

/**
* get the client netDb for the given id
*
* @since 0.9.60
*
*/
@Override
public FloodfillNetworkDatabaseFacade clientNetDB(Hash id) {
if (id != null)
return getSubNetDB(id.toBase32());
return exploratoryNetDB();
}

/**
* get the default client netDb
*
* @since 0.9.60
*
*/
public FloodfillNetworkDatabaseFacade clientNetDB() {
return exploratoryNetDB();
}

/**
* get the default client netDb
*
* @since 0.9.60
*
*/
@Override
public FloodfillNetworkDatabaseFacade exploratoryNetDB() {
return _exploratoryDbid;
}

/**
* look up the dbid of the client with the given signing public key
*
* @since 0.9.60
*
*/
@Override
public List<String> lookupClientBySigningPublicKey(SigningPublicKey spk) {
List<String> rv = new ArrayList<>();
Expand Down Expand Up @@ -324,6 +430,12 @@ private String matchDbid(Hash clientKey) {
return null;
}

/**
* get all the subDbs and return them in a Set.
*
* @since 0.9.60
*
*/
@Override
public Set<FloodfillNetworkDatabaseFacade> getSubNetDBs() {
Set<FloodfillNetworkDatabaseFacade> rv = new HashSet<>();
Expand All @@ -334,6 +446,12 @@ public Set<FloodfillNetworkDatabaseFacade> getSubNetDBs() {
return rv;
}

/**
* list of the BlindData objects for all known clients
*
* @since 0.9.60
*
*/
@Override
public List<BlindData> getLocalClientsBlindData() {
List<BlindData> rv = new ArrayList<>();
Expand Down

0 comments on commit 03a131c

Please sign in to comment.