net.i2p.router.networkdb.kademlia

## Class StoreState

- java.lang.Object
- - net.i2p.router.networkdb.kademlia.StoreState

-     class StoreState
      extends Object

  Manages state for network database store operations.

  Tracks peer interaction status, timing information, and operation progress for store operations. Maintains separate sets for pending, attempted, and successful operations to coordinate concurrent store operations and prevent duplicate queries.

  Thread-safe implementation using synchronized collections and atomic counters for safe concurrent access from multiple store jobs.

  Provides comprehensive state management for reliable data persistence with validation, timeout handling, and operation completion tracking.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StoreState(RouterContext ctx, Hash key, DatabaseEntry data)`
    `StoreState(RouterContext ctx, Hash key, DatabaseEntry data, Set<Hash> toSkip)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPending(Hash peer)` Increments attempted count
    `void` | `addPending(Hash peer, MessageWrapper.WrappedMessage msg)`
    `void` | `addSkipped(Hash peer)` we aren't even going to try to contact this peer
    `void` | `complete(boolean completed)`
    `boolean` | `completed()`
    `long` | `confirmed(Hash peer)`
    `Set<Hash>` | `getAttempted()` The peers attempted OR skipped.
    `int` | `getAttemptedCount()` The number of peers attempted.
    `int` | `getCompleteCount()`
    `DatabaseEntry` | `getData()`
    `int` | `getPendingCount()`
    `MessageWrapper.WrappedMessage` | `getPendingMessage(Hash peer)`
    `Hash` | `getSuccessful()` Return a successful peer (a random one if more than one was successful) or null.
    `Hash` | `getTarget()`
    `long` | `getWhenCompleted()`
    `long` | `getWhenStarted()`
    `void` | `replyTimeout(Hash peer)`
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### StoreState

          public StoreState(RouterContext ctx,
                            Hash key,
                            DatabaseEntry data)

    - #### StoreState

          public StoreState(RouterContext ctx,
                            Hash key,
                            DatabaseEntry data,
                            Set<Hash> toSkip)

      Parameters:
        `key` - the DatabaseEntry hash
        `toSkip` - may be null, if non-null, all attempted and skipped targets will be added as of 0.9.53

  - ### Method Detail

    - #### addPending

          public void addPending(Hash peer)

      Increments attempted count

    - #### addPending

          public void addPending(Hash peer,
                                 MessageWrapper.WrappedMessage msg)

    - #### addSkipped

          public void addSkipped(Hash peer)

      we aren't even going to try to contact this peer

    - #### complete

          public void complete(boolean completed)

    - #### completed

          public boolean completed()

    - #### confirmed

          public long confirmed(Hash peer)

    - #### getAttempted

          public Set<Hash> getAttempted()

      The peers attempted OR skipped. DOES include skipped peers. Use getAttemptedCount for the number of attempts.

    - #### getAttemptedCount

          public int getAttemptedCount()

      The number of peers attempted. Does not include skipped peers. Do not use getAttempted().size() as that does include skipped peers.

    - #### getCompleteCount

          public int getCompleteCount()

    - #### getData

          public DatabaseEntry getData()

    - #### getPendingCount

          public int getPendingCount()

    - #### getPendingMessage

          public MessageWrapper.WrappedMessage getPendingMessage(Hash peer)

    - #### getSuccessful

          public Hash getSuccessful()

      Return a successful peer (a random one if more than one was successful) or null.

    - #### getTarget

          public Hash getTarget()

    - #### getWhenCompleted

          public long getWhenCompleted()

    - #### getWhenStarted

          public long getWhenStarted()

    - #### replyTimeout

          public void replyTimeout(Hash peer)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`