Class UtxComparableData

java.lang.Object
nxt.blockchain.UtxComparableData
All Implemented Interfaces:
Comparable<UtxComparableData>

public final class UtxComparableData extends Object implements Comparable<UtxComparableData>
Represents the data which is used to prioritize UnconfirmedTransactions in the unconfirmed pool.
  • Field Details

  • Constructor Details

    • UtxComparableData

      public UtxComparableData(Transaction transaction, boolean isBundled, boolean isCompleteAtomicChain, long arrivalTimestamp, long fee, int fullSize)
  • Method Details

    • compareTo

      public int compareTo(UtxComparableData that)
      Specified by:
      compareTo in interface Comparable<UtxComparableData>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • cloneIgnoringTimeAndId

      public UtxComparableData cloneIgnoringTimeAndId(long newArrivalTimestamp, long newId)
    • filterWithLimits

      public static <T> List<T> filterWithLimits(Stream<T> stream, Function<T,UtxComparableData> mapper, int minSize, int maxSize, UtxComparableData retentionThreshold, BiConsumer<T,UtxComparableData> rejectedElementConsumer)
      This method obtains a `UtxComparableData` object for each element in the stream using the specified mapper. It then sorts the elements based on the `UtxComparableData`. After sorting, elements are removed from the end of the sorted list until the list size is reduced to either the retentionThreshold or minSize, whichever is larger. The list size is also limited by maxSize. The list is returned as result.
      Type Parameters:
      T - Type of the stream elements
      Parameters:
      stream - Stream to sort and filter
      mapper - Mapper returning the UtxComparableData of the elements
      minSize - The minimum size of the returned array. If the collection size is smaller, this value is capped to the collection size
      maxSize - The maximum size of the returned array
      retentionThreshold - Elements bigger than this threshold will always be retained. If null, only the maxSize is respected
      rejectedElementConsumer - If not null the rejected elements will be provided to it
      Returns:
      List with the result