java.lang.Object
net.i2p.router.NetworkDatabaseFacade
- All Implemented Interfaces:
Service
- Direct Known Subclasses:
DummyNetworkDatabaseFacade, KademliaNetworkDatabaseFacade
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThe abstract facade holds no state of its own; subclasses initialize themselves through their own constructors.Method Summary
Modifier and TypeMethodDescriptionabstract voidaccessLeaseSet(Hash key) Record access to a LeaseSet for refresh tracking.abstract voidMark a database entry as failed.findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore) Return the RouterInfo structures for the routers closest to the given key.booleanFor convenience, so users don't have to cast to FNDF, and unit tests using Dummy NDF will work.All known router hashes.The blind data for the given unblinded key, for console ConfigKeyringHelper.Look up the cached BlindData for the given key.The known client LeaseSets.long[]Debug overview stats: total keys, bucket count, per-bucket capacity and fullest bucket size, as {keys, buckets, capacity, fullest}.The known floodfill LeaseSets.intNumber of known LeaseSets.intNumber of known routers.longThe last time we successfully published our RI.All known LeaseSets for display.The known published LeaseSets.Public for NetDbRenderer in routerconsole.The known unpublished LeaseSets.booleanIs the network database initialized?booleanIs it permanently negative cached?abstract voidlookupDestination(Hash key, Job onFinishedJob, long timeoutMs, Hash fromLocalDest) Lookup using the client's tunnels Succeeds even if LS validation fails due to unsupported sig type.abstract DestinationLookup locally in netDB and in badDest cache Succeeds even if LS validation failed due to unsupported sig type.abstract voidlookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) Lookup a LeaseSet in the network database.abstract voidlookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Lookup using the client's tunnels.abstract LeaseSetLook up a LeaseSet in the local network database.abstract voidlookupLeaseSetRemotely(Hash key, Hash fromLocalDest) Unconditionally lookup using the client's tunnels.abstract voidlookupLeaseSetRemotely(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Unconditionally lookup using the client's tunnels.abstract DatabaseEntrylookupLocally(Hash key) Lookup a database entry locally.abstract DatabaseEntryNot for use without validation.abstract voidlookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) Look up a RouterInfo in the network database.abstract RouterInfoLook up a RouterInfo in the local network database.abstract voidPublish a LeaseSet to the network database.abstract voidpublish(RouterInfo localRouterInfo) Publish a RouterInfo to the network database.voidTrigger a retroactive purge sweep of the NetDb.booleanFor console ConfigKeyringHelper.abstract voidRemove a LeaseSet from refresh tracking.voidrenderStatusHTML(Writer out) Debug only - all user info moved to NetDbRenderer in router console.voidrescan()Rescan the network database.The reseed checker; the base facade has none, FNDF overrides this.voidNotify the netDB that the routing key changed at midnight UTC.voidCache the given BlindData for later lookup.store(Hash key, DatabaseEntry entry) Store a DatabaseEntry in the network database.abstract LeaseSetStore a LeaseSet in the network database.abstract RouterInfostore(Hash key, RouterInfo routerInfo) Store a RouterInfo in the network database.abstract voidUnpublish a LeaseSet from the network database.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Details
NetworkDatabaseFacade
protected NetworkDatabaseFacade()The abstract facade holds no state of its own; subclasses initialize themselves through their own constructors.
Method Details
findNearestRouters
Return the RouterInfo structures for the routers closest to the given key. At most maxNumRouters will be returned.- Parameters:
key- the hash to measure Kademlia distance from, normally our own router hashmaxNumRouters- The maximum number of routers to returnpeersToIgnore- Hash of routers not to include- Returns:
- set of router hashes closest to the key
lookupLocally
Lookup a database entry locally.- Parameters:
key- the hash of the RouterInfo or LeaseSet to look up- Returns:
- RouterInfo, LeaseSet, or null
lookupLocallyWithoutValidation
Not for use without validation.- Parameters:
key- the hash of the RouterInfo or LeaseSet to look up- Returns:
- RouterInfo, LeaseSet, or null, NOT validated
lookupLeaseSet
Lookup a LeaseSet in the network database.- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in milliseconds
lookupLeaseSet
public abstract void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Lookup using the client's tunnels.- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupLeaseSetLocally
lookupRouterInfo
public abstract void lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) Look up a RouterInfo in the network database.- Parameters:
key- the router hash whose RouterInfo is soughtonFindJob- job to run on successonFailedLookupJob- job to run on failuretimeoutMs- timeout in milliseconds
lookupRouterInfoLocally
Look up a RouterInfo in the local network database.- Parameters:
key- the router hash whose RouterInfo is sought- Returns:
- the RouterInfo, or null if not found
lookupLeaseSetRemotely
Unconditionally lookup using the client's tunnels. No success or failed jobs, no local lookup, no checks. Use this to refresh a leaseset before expiration.- Parameters:
key- the destination hash whose LeaseSet is soughtfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupLeaseSetRemotely
public abstract void lookupLeaseSetRemotely(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) Unconditionally lookup using the client's tunnels.- Parameters:
key- the destination hash whose LeaseSet is soughtonFindJob- may be nullonFailedLookupJob- may be nulltimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupDestination
public abstract void lookupDestination(Hash key, Job onFinishedJob, long timeoutMs, Hash fromLocalDest) Lookup using the client's tunnels Succeeds even if LS validation fails due to unsupported sig type.- Parameters:
key- the destination hash whose LeaseSet is soughtonFinishedJob- job to run on successtimeoutMs- timeout in millisecondsfromLocalDest- use these tunnels for the lookup, or null for exploratory
lookupDestinationLocally
Lookup locally in netDB and in badDest cache Succeeds even if LS validation failed due to unsupported sig type.- Parameters:
key- the destination hash to look up- Returns:
- the Destination, or null if it is not known or is cached as bad
store
Store a LeaseSet in the network database.- Parameters:
key- the destination hash to file the LeaseSet underleaseSet- the LeaseSet to store- Returns:
- the leaseSet if another leaseSet already existed at that key
- Throws:
IllegalArgumentException- if the data is not valid
accessLeaseSet
Record access to a LeaseSet for refresh tracking. Only tracks if we have tunnels built AND there's a hostname.- Parameters:
key- the destination hash of the LeaseSet that was used
removeLeaseSetFromTracking
Remove a LeaseSet from refresh tracking. Call this after HostChecker completes to avoid unnecessary refreshes.- Parameters:
key- the destination hash of the LeaseSet to stop tracking
store
Store a RouterInfo in the network database.- Parameters:
key- the router hash to file the RouterInfo underrouterInfo- the RouterInfo to store- Returns:
- the routerInfo if another router already existed at that key
- Throws:
IllegalArgumentException- if the data is not valid
store
Store a DatabaseEntry in the network database.- Parameters:
key- the hash to file the entry underentry- the entry to store- Returns:
- the old entry if it already existed at that key
- Throws:
IllegalArgumentException- if the data is not valid
publish
Publish a RouterInfo to the network database.- Parameters:
localRouterInfo- the RouterInfo to publish- Throws:
IllegalArgumentException- if the local router is not valid
publish
Publish a LeaseSet to the network database.- Parameters:
localLeaseSet- the LeaseSet to publish
unpublish
Unpublish a LeaseSet from the network database.- Parameters:
localLeaseSet- the LeaseSet to unpublish
fail
Mark a database entry as failed.- Parameters:
dbEntry- the key of the entry to fail
getLastRouterInfoPublishTime
public long getLastRouterInfoPublishTime()The last time we successfully published our RI.- Returns:
- the timestamp, or 0
getAllRouters
getKnownRouters
public int getKnownRouters()Number of known routers.- Returns:
- the count, 0 in this do-nothing base implementation
getKnownLeaseSets
public int getKnownLeaseSets()Number of known LeaseSets.- Returns:
- the count, 0 in this do-nothing base implementation
isInitialized
public boolean isInitialized()Is the network database initialized?- Returns:
- true if initialized
rescan
public void rescan()Rescan the network database.renderStatusHTML
Debug only - all user info moved to NetDbRenderer in router console.- Specified by:
renderStatusHTMLin interfaceService- Parameters:
out- the writer to write to- Throws:
IOException- if an error occurs writing
getDebugStats
public long[] getDebugStats()Debug overview stats: total keys, bucket count, per-bucket capacity and fullest bucket size, as {keys, buckets, capacity, fullest}. Null where the facade has no kademlia buckets.- Returns:
- the stats, or null
getLeases
getRouters
Public for NetDbRenderer in routerconsole.- Returns:
- the set of known RouterInfos, empty in the base facade
getClientLeases
getPublishedLeases
getUnpublishedLeases
getFloodfillLeases
reseedChecker
The reseed checker; the base facade has none, FNDF overrides this.- Returns:
- the reseed checker, or null in the base facade
floodfillEnabled
public boolean floodfillEnabled()For convenience, so users don't have to cast to FNDF, and unit tests using Dummy NDF will work.- Returns:
- false; FNDF overrides to return actual setting
isNegativeCachedForever
Is it permanently negative cached?- Parameters:
key- only for Destinations; for RouterIdentities, see Banlist- Returns:
- whether negative cached forever
getBlindData
Look up the cached BlindData for the given key.- Parameters:
spk- unblinded key- Returns:
- BlindData or null
setBlindData
Cache the given BlindData for later lookup.- Parameters:
bd- new BlindData to put in the cache
getBlindData
removeBlindData
For console ConfigKeyringHelper.- Parameters:
spk- the signing key whose blind data is to be dropped- Returns:
- true if removed
routingKeyChanged
public void routingKeyChanged()Notify the netDB that the routing key changed at midnight UTC.purgeMatchingRouters
public void purgeMatchingRouters()Trigger a retroactive purge sweep of the NetDb. Bans and removes all routers matching enabled LU/XG/custom-cap bans.