UNPKG

@cronstamp/clientlib

Version:

Client library for cronstamp, a blockchain-based document timestamping and verification service.

47 lines 1.85 kB
export declare function sleep_s(seconds: number): Promise<void>; export declare function sleep_ms(milliseconds: number): Promise<void>; /** * Get time until next attempt using exponential backoff * Defaults to 1.35^attempt seconds. This results in about four minutes total time for 15 attempts. * The first attempt always runs immediately */ export declare class ExponentialBackoff { startTime: number; lastSleepTime: number; attempt: number; maxAttempts: number; private readonly interval; private readonly rate; /** * Exponential backoff starting at a specified time * Defaults to 1.35^attempt seconds. This results in about four minutes total time for 15 attempts. * * @param maxAttempts attempt at which to stop (exclusive, starting at 0) * @param interval * @param rate * @param startTime unix timestamp in ms */ constructor(maxAttempts?: number, rate?: number, interval?: number, startTime?: number); /** * Get the delay until next attempt, assuming the last attempt was the previous index. Time elapsed since the last call is subtracted from the delay. * Attempt 0 is always immediate. */ getDelayForNextAttempt(): number; /** * Wait for the next attempt. Time elapsed since the last call is subtracted from the delay. * Attempt 0 is always immediate. * Increases internal attempt counter * * @returns true, if waited for the time of the current step, false if the maxAttempt was reached */ waitForNextAttempt(): Promise<boolean>; /** * Gets the total time in milliseconds this exponential backoff will take, if all attempts are used. */ getTotalTime(): number; /** * Returns true, if there are attempts left */ isActive(): boolean; } //# sourceMappingURL=time.d.ts.map