Class ExponentialBackoff

java.lang.Object
org.bitcoinj.utils.ExponentialBackoff
All Implemented Interfaces:
Comparable<ExponentialBackoff>

public class ExponentialBackoff extends Object implements Comparable<ExponentialBackoff>

Tracks successes and failures and calculates a time to retry the operation.

The retries are exponentially backed off, up to a maximum interval. On success the back off interval is reset.

  • Field Details

    • DEFAULT_INITIAL_INTERVAL

      public static final Duration DEFAULT_INITIAL_INTERVAL
    • DEFAULT_MULTIPLIER

      public static final float DEFAULT_MULTIPLIER
      See Also:
    • DEFAULT_MAXIMUM_INTERVAL

      public static final Duration DEFAULT_MAXIMUM_INTERVAL
  • Constructor Details

  • Method Details

    • trackSuccess

      public final void trackSuccess()
      Track a success - reset back off interval to the initial value
    • trackFailure

      public void trackFailure()
      Track a failure - multiply the back off interval by the multiplier
    • retryTime

      public Instant retryTime()
      Get the next time to retry
    • getRetryTime

      @Deprecated public long getRetryTime()
      Deprecated.
      Get the next time to retry, in milliseconds since the epoch
    • compareTo

      public int compareTo(ExponentialBackoff other)
      Specified by:
      compareTo in interface Comparable<ExponentialBackoff>
    • toString

      public String toString()
      Overrides:
      toString in class Object