From 03a131c3c0adc5e36d1adac2cc09d5b77569bf7e Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Mon, 18 Sep 2023 00:17:40 -0400 Subject: [PATCH] Router: FNDS javadoc --- .../FloodfillNetworkDatabaseSegmentor.java | 124 +++++++++++++++++- 1 file changed, 121 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java index a26b013c84..67cc94fa34 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseSegmentor.java @@ -86,6 +86,13 @@ 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) @@ -93,6 +100,13 @@ public FloodfillNetworkDatabaseFacade getSubNetDB(Hash id) { 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)) @@ -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 @@ -133,12 +149,18 @@ public synchronized void shutdown() { } } + /** + * list of the RouterInfo objects for all known peers; + * + * @since 0.9.60 + * + */ public List getKnownRouterData() { List rv = new ArrayList(); 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()); } @@ -149,6 +171,8 @@ public List 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 getFloodfillPeers() { List peers = new ArrayList(); @@ -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()) { @@ -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) { @@ -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 getRouters() { Set rv = new HashSet<>(); @@ -221,6 +265,14 @@ public Set getRouters() { return rv; } + + + /** + * list of the RouterInfo objects for all known peers known to clients(in subDbs) only + * + * @since 0.9.60 + * + */ public Set getRoutersKnownToClients() { Set rv = new HashSet<>(); for (String key : getClients()) { @@ -229,6 +281,12 @@ public Set getRoutersKnownToClients() { return rv; } + /** + * list of the LeaseSet objects for all known peers known to clients(in subDbs) only + * + * @since 0.9.60 + * + */ public Set getLeasesKnownToClients() { Set rv = new HashSet<>(); for (String key : getClients()) { @@ -237,6 +295,12 @@ public Set getLeasesKnownToClients() { return rv; } + /** + * list all of the dbids of all known client subDbs + * + * @since 0.9.60 + * + */ public List getClients() { List rv = new ArrayList(); for (String key : _subDBs.keySet()) { @@ -248,16 +312,34 @@ public List 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()) @@ -265,6 +347,12 @@ public FloodfillNetworkDatabaseFacade clientNetDB(String id) { 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) @@ -272,15 +360,33 @@ public FloodfillNetworkDatabaseFacade clientNetDB(Hash id) { 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 lookupClientBySigningPublicKey(SigningPublicKey spk) { List rv = new ArrayList<>(); @@ -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 getSubNetDBs() { Set rv = new HashSet<>(); @@ -334,6 +446,12 @@ public Set getSubNetDBs() { return rv; } + /** + * list of the BlindData objects for all known clients + * + * @since 0.9.60 + * + */ @Override public List getLocalClientsBlindData() { List rv = new ArrayList<>();