java.lang.Object
net.i2p.kademlia.RandomTrimmer<T>
net.i2p.kademlia.RandomIfOldTrimmer<T>
Type Parameters:
T - type of SimpleDataStructure objects in the bucket
All Implemented Interfaces:
KBucketTrimmer<T>

public class RandomIfOldTrimmer<T extends SimpleDataStructure>extends RandomTrimmer<T>
Removes a random element, but only if the bucket hasn't changed in 5 minutes.
  • Constructor Details

    • RandomIfOldTrimmer

      public RandomIfOldTrimmer(I2PAppContext ctx, int max)
      Create a trimmer that only trims a bucket that hasn't changed in 5 minutes.
      Parameters:
      ctx - the application context, supplying the clock used to decide staleness
      max - maximum bucket size
  • Method Details

    • trim

      public boolean trim(KBucket<T> kbucket, T toAdd)
      Description copied from interface: KBucketTrimmer
      Called from add() just before adding the entry. You may call getEntries() and/or remove() from here. Do NOT call add(). To always discard a newer entry, always return false.
      Specified by:
      trim in interface KBucketTrimmer<T extends SimpleDataStructure>
      Overrides:
      trim in class RandomTrimmer<T extends SimpleDataStructure>
      Parameters:
      kbucket - the kbucket that is now too big
      toAdd - the entry the bucket is about to accept
      Returns:
      true to actually add the entry.