java.lang.Object
org.klomp.snark.dht.PersistDHT

abstract class PersistDHTextends Object
Retrieve / Store the local DHT in a file.

Provides static methods to load and save the DHT routing table to persistent storage. The DHT node list is stored in a simple text format with one node per line.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    On a routine save, entries older than this (one hour in ms) are dropped; a full save keeps everything.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for subclasses; the load and save helpers in this base class are static.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    static void
    loadDHT(KRPC krpc, File file)
    Load the DHT from a single file.
    static void
    loadDHT(KRPC krpc, File file, File backupFile)
    Load the DHT from file, trying the backup if the primary doesn't exist.
    static void
    saveDHT(DHTNodes nodes, boolean saveAll, File file)
    Save the DHT to a file.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_AGE

      private static final long MAX_AGE
      On a routine save, entries older than this (one hour in ms) are dropped; a full save keeps everything.
      See Also:
  • Constructor Details

    • PersistDHT

      PersistDHT()
      Constructor for subclasses; the load and save helpers in this base class are static.
  • Method Details

    • loadDHT

      public static void loadDHT(KRPC krpc, File file, File backupFile)
      Load the DHT from file, trying the backup if the primary doesn't exist.
      Parameters:
      krpc - the KRPC instance to load nodes into
      file - the primary DHT file
      backupFile - may be null
    • loadDHT

      public static void loadDHT(KRPC krpc, File file)
      Load the DHT from a single file.
      Parameters:
      krpc - the KRPC instance to load nodes into
      file - the DHT file to load
    • saveDHT

      public static void saveDHT(DHTNodes nodes, boolean saveAll, File file)
      Save the DHT to a file.
      Parameters:
      nodes - the DHT nodes to save
      saveAll - if true, don't check last seen time
      file - the file to write to