java.lang.Object
net.i2p.router.sybil.PersistSybil

public class PersistSybilextends Object
Store and retrieve analysis files from disk. Each file is named with a timestamp.
  • Field Details

  • Constructor Details

    • PersistSybil

      public PersistSybil(I2PAppContext ctx)
      Create a new PersistSybil instance.
      Parameters:
      ctx - the router context
  • Method Details

    • store

      public void store(long date, Map<Hash,Points> entries) throws IOException
      Store each entry.
      Parameters:
      date - the timestamp for the file
      entries - each one should be "entry" at the root
      Throws:
      IOException - if an I/O error occurs
    • load

      public List<Long> load()
      The list of stored analysis sets, as a time stamp.
      Returns:
      non-null, sorted by updated date, newest first
    • load

      public Map<Hash,Points> load(long date) throws IOException
      Load the analysis for a certain date.
      Parameters:
      date - the timestamp for the file
      Returns:
      non-null, unsorted
      Throws:
      IOException - if an I/O error occurs
    • load

      public Map<Long,Points> load(Hash h) throws IOException
      Load all the analysis for a certain hash.
      Parameters:
      h - the hash to load
      Returns:
      non-null, unsorted
      Throws:
      IOException - if an I/O error occurs
    • removeOld

      public void removeOld()
      Remove all files older than configured threshold Inline for now, thread later if necessary.
    • delete

      public boolean delete(long date)
      Delete the file for a particular date.
      Parameters:
      date - the timestamp for the file
      Returns:
      true if the file was deleted
    • getBlocklistFile

      public File getBlocklistFile()
      Get the blocklist path.
      Returns:
      the blocklist file
    • deleteBlocklistFile

      public void deleteBlocklistFile()
      Delete the blocklist.
    • readBlocklist

      Map<String,Long> readBlocklist()
      Read the blocklist.
      Returns:
      map of ip or hash to expiration (ms), or null on failure
    • readBlocklist

      private Map<String,Long> readBlocklist(File blFile)
      Read the blocklist.
      Parameters:
      blFile - the blocklist file to read
      Returns:
      map of ip or hash to expiration (ms), or null on failure
    • storeBlocklist

      void storeBlocklist(Set<String> blocks, long blockUntil)
      Write the blocklist. The format is different than other blocklists because we include an expiration. Format: One per line: ip or hash,expiration time (ms).
      Parameters:
      blocks - non-empty, will be merged with existing entries
      blockUntil - the expiration time in ms
    • notifyVersion

      private void notifyVersion(long v)
      Notify the update manager of a new blocklist version.
      Parameters:
      v - the newly installed blocklist version number