net.i2p.router.sybil

## Class PersistSybil

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

-     public class PersistSybil
      extends Object

  Store and retrieve analysis files from disk. Each file is named with a timestamp.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistSybil(I2PAppContext ctx)` access via Analysis.getPersister()

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `delete(long date)` Delete the file for a particular date
    `void` | `deleteBlocklistFile()` Delete the blocklist
    `File` | `getBlocklistFile()` Get the blocklist path
    `List<Long>` | `load()` The list of stored analysis sets, as a time stamp.
    `Map<Long,Points>` | `load(Hash h)` Load all the analysis for a certain hash.
    `Map<Hash,Points>` | `load(long date)` Load the analysis for a certain date.
    `(package private) Map<String,Long>` | `readBlocklist()` Read the blocklist
    `void` | `removeOld()` Remove all files older than configured threshold Inline for now, thread later if necessary
    `void` | `store(long date, Map<Hash,Points> entries)` Store each entry.
    `(package private) void` | `storeBlocklist(Set<String> blocks, long blockUntil)` Write the blocklist.

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

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

- - ### Constructor Detail

    - #### PersistSybil

          public PersistSybil(I2PAppContext ctx)

      access via Analysis.getPersister()

  - ### Method Detail

    - #### delete

          public boolean delete(long date)

      Delete the file for a particular date
      Returns:
        success

    - #### deleteBlocklistFile

          public void deleteBlocklistFile()

      Delete the blocklist

    - #### getBlocklistFile

          public File getBlocklistFile()

      Get the blocklist path

    - #### 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<Long,Points> load(Hash h)
                                throws IOException

      Load all the analysis for a certain hash.
      Returns:
        non-null, unsorted
      Throws:
        `IOException`

    - #### load

          public Map<Hash,Points> load(long date)
                                throws IOException

      Load the analysis for a certain date.
      Returns:
        non-null, unsorted
      Throws:
        `IOException`

    - #### readBlocklist

          Map<String,Long> readBlocklist()

      Read the blocklist
      Returns:
        map of ip or hash to expiration (ms), or null on failure

    - #### removeOld

          public void removeOld()

      Remove all files older than configured threshold Inline for now, thread later if necessary

    - #### store

          public void store(long date,
                            Map<Hash,Points> entries)
                     throws IOException

      Store each entry.
      Parameters:
        `entries` - each one should be "entry" at the root
      Throws:
        `IOException`

    - #### 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 or hash|ip,expiration time (ms)
      Parameters:
        `blocks` - non-empty, will be merged with existing entries