@kyve/core-beta
Version:
🚀 The base KYVE node implementation.
83 lines (82 loc) • 2.54 kB
TypeScript
/// <reference types="node" />
import { DataItem } from "..";
/**
* Waits for a specific amount of time
*
* @method sleep
* @param {number} timeoutMs
* @return {Promise<void>}
*/
export declare const sleep: (timeoutMs: number) => Promise<void>;
/**
* Standardizes any JSON object
*
* @method standardizeJSON
* @param {any} object
* @return {any}
*/
export declare const standardizeJSON: (object: any) => any;
/**
* Transforms a data bundle to raw bytes
*
* @method bundleToBytes
* @param {DataItem[]} bundle
* @return {Buffer}
*/
export declare const bundleToBytes: (bundle: DataItem[]) => Buffer;
/**
* Transforms raw bytes to a data bundle
*
* @method bytesToBundle
* @param {DataItem[]} bundle
* @return {Buffer}
*/
export declare const bytesToBundle: (bytes: Buffer) => DataItem[];
/**
* Creates a sha256 hash of raw byte data
*
* @method sha256
* @param {Buffer} data
* @return {string}
*/
export declare const sha256: (data: Buffer) => string;
/**
* Formats any bignumber into a human readable format
*
* @method toHumanReadable
* @param {string} amount
* @param {number} precision defines how many decimals after the comma should be returned
* @return {string}
*/
export declare const toHumanReadable: (amount: string, precision?: number) => string;
/**
* Generates every index pair of an array length n. Note that this
* method is O(n^2)
*
* @method generateIndexPairs
* @param {number} n length of array
* @return {[number, number][]}
*/
export declare const generateIndexPairs: (n: number) => [number, number][];
type OptionsRetryerType = {
limitTimeoutMs: number;
increaseByMs: number;
maxRequests?: number;
};
type onErrorRetryerType = (value: Error, ctx: {
nextTimeoutInMs: number;
numberOfRetries: number;
options: OptionsRetryerType;
}) => void;
/**
* Calls any async function with a backoff strategy which behaviour
* can be defined with options
*
* @method callWithBackoffStrategy
* @param {() => Promise<T>} execution the method to execute with a backoff strategy
* @param {OptionsRetryerType} options defines the backoff strategy. e.g the number of retries or the timeout limit
* @param {onErrorRetryerType} onError a method which gets called if specified and if an error occurs calling the execution method
* @return {Promise<T>} returns what the execution method returns
*/
export declare function callWithBackoffStrategy<T>(execution: () => Promise<T>, options: OptionsRetryerType, onError?: onErrorRetryerType): Promise<T>;
export {};