All Known Implementing Classes:
PersistentDataStore, TransientDataStore

public interface DataStore
Interface for database storage operations in the network database.

Provides methods for storing, retrieving, and managing database entries including RouterInfo and LeaseSet objects with optional persistence control.

  • Method Details

    • isInitialized

      boolean isInitialized()
      Check if the data store has been initialized.
      Returns:
      true if the store is ready for operations
    • isKnown

      boolean isKnown(Hash key)
      Check if the given key exists in the data store.
      Parameters:
      key - the hash key to look up
      Returns:
      true if the key is known and stored
    • get

      DatabaseEntry get(Hash key)
      Retrieve the database entry for the given key.
      Parameters:
      key - the hash key to look up
      Returns:
      the database entry, or null if not found
    • get

      DatabaseEntry get(Hash key, boolean persist)
      Retrieve the database entry for the given key with optional persistence control.
      Parameters:
      key - the hash key to look up
      persist - if true, keep the entry in persistent storage
      Returns:
      the database entry, or null if not found
    • put

      boolean put(Hash key, DatabaseEntry data)
      Store a database entry with the given key.
      Parameters:
      key - the hash key to store under
      data - the database entry to store
      Returns:
      true if the store was successful
    • put

      boolean put(Hash key, DatabaseEntry data, boolean persist)
      Store a database entry with the given key and persistence control.
      Parameters:
      key - the hash key to store under
      data - the database entry to store
      persist - if true, keep the entry in persistent storage
      Returns:
      true if the store was successful
    • forcePut

      boolean forcePut(Hash key, DatabaseEntry data)
      Unconditionally store, bypass all newer/older checks.
      Parameters:
      key - non-null
      data - non-null
      Returns:
      true if the entry was stored in the Kademlia structure
    • remove

      DatabaseEntry remove(Hash key)
      Remove the entry for the given key.
      Parameters:
      key - the hash key to remove
      Returns:
      the removed database entry, or null if not found
    • remove

      DatabaseEntry remove(Hash key, boolean persist)
      Remove the entry for the given key with optional persistence control.
      Parameters:
      key - the hash key to remove
      persist - if true, also remove from persistent storage
      Returns:
      the removed database entry, or null if not found
    • getKeys

      Set<Hash> getKeys()
      All keys stored in the data store.
      Returns:
      set of all hash keys
    • getEntries

      Collection<DatabaseEntry> getEntries()
      All entries in the data store.
      Returns:
      every entry currently held, as a live collection
    • getMapEntries

      Set<Map.Entry<Hash, DatabaseEntry>> getMapEntries()
      All map entries in the data store.
      Returns:
      the map entries
    • stop

      void stop()
      Stop the data store and release resources.
    • rescan

      void rescan()
      Rescan the storage for any changes.
    • countLeaseSets

      int countLeaseSets()
      Count the number of LeaseSet entries in the store.
      Returns:
      the number of LeaseSets stored
    • size

      int size()
      Total number of entries in the store, RouterInfos and LeaseSets together.
      Returns:
      total size (RI and LS)