backoff function

PollStrategy backoff(
  1. num startingThrottleInMsec,
  2. num backoffFactor
)

Implementation

PollStrategy backoff(num startingThrottleInMsec, num backoffFactor) {
  num currentThrottling = startingThrottleInMsec;

  return (Principal canisterId, RequestId requestId, String status) {
    var c = Completer();
    Future.delayed(Duration(milliseconds: (currentThrottling).toInt()), () {
      currentThrottling *= backoffFactor;
      c.complete();
    });
    return c.future;
  };
}