net.i2p.router.networkdb.kademlia

## Class SearchMessageSelector

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

- All Implemented Interfaces:
    MessageSelector

      class SearchMessageSelector
      extends Object
      implements MessageSelector

  Message selector for matching search operation responses from specific peers.

  Filters incoming DatabaseStoreMessage and DatabaseSearchReplyMessage to identify responses corresponding to ongoing search operations. Tracks match status, expiration times, and coordinates with SearchState to manage pending peer queries.

  Provides unique identification for each selector instance and implements continuation logic based on search progress and timeout conditions. Ensures proper response correlation between sent queries and received replies.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SearchMessageSelector(RouterContext context, RouterInfo peer, long expiration, SearchState state)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `continueMatching()` Returns true if the selector should still keep searching for further matches.
    `long` | `getExpiration()` Returns the # of milliseconds since the epoch after which this selector should stop searching for matches.
    `boolean` | `isMatch(I2NPMessage message)` Returns true if the received message matches the selector.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### SearchMessageSelector

          public SearchMessageSelector(RouterContext context,
                                       RouterInfo peer,
                                       long expiration,
                                       SearchState state)

  - ### Method Detail

    - #### continueMatching

          public boolean continueMatching()

      Description copied from interface: `MessageSelector`
      Returns true if the selector should still keep searching for further matches. This is called only if isMatch() returns true. If this returns true, isMatch() will not be called again.
      Specified by:
        `continueMatching` in interface `MessageSelector`

    - #### getExpiration

          public long getExpiration()

      Description copied from interface: `MessageSelector`
      Returns the # of milliseconds since the epoch after which this selector should stop searching for matches. At some time after expiration, if continueMatching() has not returned false, the job specified by OutNetMessage.getOnFailedReplyJob() will be run for every OutNetMessage associated with this selector (by OutboundMessageRegistry).
      Specified by:
        `getExpiration` in interface `MessageSelector`

    - #### isMatch

          public boolean isMatch(I2NPMessage message)

      Description copied from interface: `MessageSelector`
      Returns true if the received message matches the selector. If this returns true, the job specified by OutNetMessage.getOnReplyJob() will be run for every OutNetMessage associated with this selector (by InNetMessagePool), after calling setMessage() for that ReplyJob. WARNING this is called from within OutboundMessageSelector.getOriginalMessages() inside a lock and can lead to deadlocks if the selector does too much in isMatch(). Until the lock is removed, take care to keep it simple.
      Specified by:
        `isMatch` in interface `MessageSelector`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`