net.i2p.router

## Class NetworkDatabaseFacade

- java.lang.Object
- - net.i2p.router.NetworkDatabaseFacade

- All Implemented Interfaces:
    Service
  Direct Known Subclasses:
    DummyNetworkDatabaseFacade, KademliaNetworkDatabaseFacade

      public abstract class NetworkDatabaseFacade
      extends Object
      implements Service

  Abstract interface for I2P network database operations. Provides router info and lease set lookup, storage, and search functionality for peer discovery and routing.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NetworkDatabaseFacade()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `fail(Hash dbEntry)`
    `abstract Set<Hash>` | `findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore)` Return the RouterInfo structures for the routers closest to the given key.
    `boolean` | `floodfillEnabled()` For convenience, so users don't have to cast to FNDF, and unit tests using Dummy NDF will work.
    `abstract Set<Hash>` | `getAllRouters()`
    `List<BlindData>` | `getBlindData()` For console ConfigKeyringHelper
    `BlindData` | `getBlindData(SigningPublicKey spk)`
    `Set<LeaseSet>` | `getClientLeases()` public for NetDbRenderer in routerconsole
    `Set<LeaseSet>` | `getFloodfillLeases()` public for NetDbRenderer in routerconsole
    `int` | `getKnownLeaseSets()`
    `int` | `getKnownRouters()`
    `long` | `getLastRouterInfoPublishTime()` The last time we successfully published our RI.
    `Set<LeaseSet>` | `getLeases()` public for NetDbRenderer in routerconsole
    `Set<LeaseSet>` | `getPublishedLeases()` public for NetDbRenderer in routerconsole
    `Set<RouterInfo>` | `getRouters()` public for NetDbRenderer in routerconsole
    `Set<LeaseSet>` | `getUnpublishedLeases()` public for NetDbRenderer in routerconsole
    `boolean` | `isInitialized()`
    `boolean` | `isNegativeCachedForever(Hash key)` Is it permanently negative cached?
    `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
    `abstract Destination` | `lookupDestinationLocally(Hash key)` Lookup locally in netDB and in badDest cache Succeeds even if LS validation failed due to unsupported sig type
    `abstract void` | `lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)`
    `abstract void` | `lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest)` Lookup using the client's tunnels
    `abstract LeaseSet` | `lookupLeaseSetLocally(Hash key)`
    `abstract void` | `lookupLeaseSetRemotely(Hash key, Hash fromLocalDest)` Unconditionally lookup using the client's tunnels.
    `abstract void` | `lookupLeaseSetRemotely(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest)` Unconditionally lookup using the client's tunnels.
    `abstract DatabaseEntry` | `lookupLocally(Hash key)`
    `abstract DatabaseEntry` | `lookupLocallyWithoutValidation(Hash key)` Not for use without validation
    `abstract void` | `lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs)`
    `abstract RouterInfo` | `lookupRouterInfoLocally(Hash key)`
    `abstract void` | `publish(LeaseSet localLeaseSet)`
    `abstract void` | `publish(RouterInfo localRouterInfo)`
    `boolean` | `removeBlindData(SigningPublicKey spk)` For console ConfigKeyringHelper
    `void` | `renderStatusHTML(Writer out)` Debug only - all user info moved to NetDbRenderer in router console
    `void` | `rescan()`
    `ReseedChecker` | `reseedChecker()`
    `void` | `routingKeyChanged()` Notify the netDB that the routing key changed at midnight UTC
    `void` | `setBlindData(BlindData bd)`
    `DatabaseEntry` | `store(Hash key, DatabaseEntry entry)`
    `abstract LeaseSet` | `store(Hash key, LeaseSet leaseSet)`
    `abstract RouterInfo` | `store(Hash key, RouterInfo routerInfo)`
    `abstract void` | `unpublish(LeaseSet localLeaseSet)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface net.i2p.router.Service

      `restart, shutdown, startup`

- - ### Constructor Detail

    - #### NetworkDatabaseFacade

          public NetworkDatabaseFacade()

  - ### Method Detail

    - #### fail

          public abstract void fail(Hash dbEntry)

    - #### findNearestRouters

          public abstract Set<Hash> findNearestRouters(Hash key,
                                                       int maxNumRouters,
                                                       Set<Hash> peersToIgnore)

      Return the RouterInfo structures for the routers closest to the given key. At most maxNumRouters will be returned
      Parameters:
        `key` - The key
        `maxNumRouters` - The maximum number of routers to return
        `peersToIgnore` - Hash of routers not to include

    - #### 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

    - #### getAllRouters

          public abstract Set<Hash> getAllRouters()

    - #### getBlindData

          public List<BlindData> getBlindData()

      For console ConfigKeyringHelper

    - #### getBlindData

          public BlindData getBlindData(SigningPublicKey spk)

      Parameters:
        `spk` - unblinded key
      Returns:
        BlindData or null

    - #### getClientLeases

          public Set<LeaseSet> getClientLeases()

      public for NetDbRenderer in routerconsole

    - #### getFloodfillLeases

          public Set<LeaseSet> getFloodfillLeases()

      public for NetDbRenderer in routerconsole

    - #### getKnownLeaseSets

          public int getKnownLeaseSets()

    - #### getKnownRouters

          public int getKnownRouters()

    - #### getLastRouterInfoPublishTime

          public long getLastRouterInfoPublishTime()

      The last time we successfully published our RI.

    - #### getLeases

          public Set<LeaseSet> getLeases()

      public for NetDbRenderer in routerconsole

    - #### getPublishedLeases

          public Set<LeaseSet> getPublishedLeases()

      public for NetDbRenderer in routerconsole

    - #### getRouters

          public Set<RouterInfo> getRouters()

      public for NetDbRenderer in routerconsole

    - #### getUnpublishedLeases

          public Set<LeaseSet> getUnpublishedLeases()

      public for NetDbRenderer in routerconsole

    - #### isInitialized

          public boolean isInitialized()

    - #### isNegativeCachedForever

          public boolean isNegativeCachedForever(Hash key)

      Is it permanently negative cached?
      Parameters:
        `key` - only for Destinations; for RouterIdentities, see Banlist

    - #### 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:
        `fromLocalDest` - use these tunnels for the lookup, or null for exploratory

    - #### lookupDestinationLocally

          public abstract Destination lookupDestinationLocally(Hash key)

      Lookup locally in netDB and in badDest cache Succeeds even if LS validation failed due to unsupported sig type

    - #### lookupLeaseSet

          public abstract void lookupLeaseSet(Hash key,
                                              Job onFindJob,
                                              Job onFailedLookupJob,
                                              long timeoutMs)

    - #### lookupLeaseSet

          public abstract void lookupLeaseSet(Hash key,
                                              Job onFindJob,
                                              Job onFailedLookupJob,
                                              long timeoutMs,
                                              Hash fromLocalDest)

      Lookup using the client's tunnels
      Parameters:
        `fromLocalDest` - use these tunnels for the lookup, or null for exploratory

    - #### lookupLeaseSetLocally

          public abstract LeaseSet lookupLeaseSetLocally(Hash key)

    - #### lookupLeaseSetRemotely

          public abstract void lookupLeaseSetRemotely(Hash key,
                                                      Hash fromLocalDest)

      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:
        `fromLocalDest` - 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:
        `fromLocalDest` - use these tunnels for the lookup, or null for exploratory
        `onFindJob` - may be null
        `onFailedLookupJob` - may be null

    - #### lookupLocally

          public abstract DatabaseEntry lookupLocally(Hash key)

      Returns:
        RouterInfo, LeaseSet, or null

    - #### lookupLocallyWithoutValidation

          public abstract DatabaseEntry lookupLocallyWithoutValidation(Hash key)

      Not for use without validation
      Returns:
        RouterInfo, LeaseSet, or null, NOT validated

    - #### lookupRouterInfo

          public abstract void lookupRouterInfo(Hash key,
                                                Job onFindJob,
                                                Job onFailedLookupJob,
                                                long timeoutMs)

    - #### lookupRouterInfoLocally

          public abstract RouterInfo lookupRouterInfoLocally(Hash key)

    - #### publish

          public abstract void publish(LeaseSet localLeaseSet)

    - #### publish

          public abstract void publish(RouterInfo localRouterInfo)
                                throws IllegalArgumentException

      Throws:
        `IllegalArgumentException` - if the local router is not valid

    - #### removeBlindData

          public boolean removeBlindData(SigningPublicKey spk)

      For console ConfigKeyringHelper
      Returns:
        true if removed

    - #### renderStatusHTML

          public void renderStatusHTML(Writer out)
                                throws IOException

      Debug only - all user info moved to NetDbRenderer in router console
      Specified by:
        `renderStatusHTML` in interface `Service`
      Throws:
        `IOException`

    - #### rescan

          public void rescan()

    - #### reseedChecker

          public ReseedChecker reseedChecker()

    - #### routingKeyChanged

          public void routingKeyChanged()

      Notify the netDB that the routing key changed at midnight UTC

    - #### setBlindData

          public void setBlindData(BlindData bd)

      Parameters:
        `bd` - new BlindData to put in the cache

    - #### store

          public DatabaseEntry store(Hash key,
                                     DatabaseEntry entry)
                              throws IllegalArgumentException

      Returns:
        the old entry if it already existed at that key
      Throws:
        `IllegalArgumentException` - if the data is not valid

    - #### store

          public abstract LeaseSet store(Hash key,
                                         LeaseSet leaseSet)
                                  throws IllegalArgumentException

      Returns:
        the leaseSet if another leaseSet already existed at that key
      Throws:
        `IllegalArgumentException` - if the data is not valid

    - #### store

          public abstract RouterInfo store(Hash key,
                                           RouterInfo routerInfo)
                                    throws IllegalArgumentException

      Returns:
        the routerInfo if another router already existed at that key
      Throws:
        `IllegalArgumentException` - if the data is not valid

    - #### unpublish

          public abstract void unpublish(LeaseSet localLeaseSet)