ethers.js/lib.esm/providers/provider-fallback.d.ts

113 lines
3.3 KiB
TypeScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
import { AbstractProvider } from "./abstract-provider.js";
import { Network } from "./network.js";
import type { PerformActionRequest } from "./abstract-provider.js";
import type { Networkish } from "./network.js";
2022-12-10 09:31:42 +03:00
/**
* A configuration entry for how to use a [[Provider]].
*/
2022-09-05 23:57:11 +03:00
export interface FallbackProviderConfig {
2023-06-02 00:52:58 +03:00
/**
* The provider.
*/
2022-09-05 23:57:11 +03:00
provider: AbstractProvider;
2023-06-02 00:52:58 +03:00
/**
* The amount of time to wait before kicking off the next provider.
*
* Any providers that have not responded can still respond and be
* counted, but this ensures new providers start.
*/
2022-09-05 23:57:11 +03:00
stallTimeout?: number;
2023-06-02 00:52:58 +03:00
/**
* The priority. Lower priority providers are dispatched first.
*/
2022-09-05 23:57:11 +03:00
priority?: number;
2023-06-02 00:52:58 +03:00
/**
* The amount of weight a provider is given against the quorum.
*/
2022-09-05 23:57:11 +03:00
weight?: number;
}
2022-12-10 09:31:42 +03:00
/**
* The statistics and state maintained for a [[Provider]].
*/
2022-09-05 23:57:11 +03:00
export interface FallbackProviderState extends Required<FallbackProviderConfig> {
2023-06-02 00:52:58 +03:00
/**
* The most recent blockNumber this provider has reported (-2 if none).
*/
2022-09-05 23:57:11 +03:00
blockNumber: number;
2023-06-02 00:52:58 +03:00
/**
* The number of total requests ever sent to this provider.
*/
2022-09-05 23:57:11 +03:00
requests: number;
2023-06-02 00:52:58 +03:00
/**
* The number of responses that errored.
*/
2022-09-05 23:57:11 +03:00
errorResponses: number;
2023-06-02 00:52:58 +03:00
/**
* The number of responses that occured after the result resolved.
*/
2022-09-05 23:57:11 +03:00
lateResponses: number;
2023-06-02 00:52:58 +03:00
/**
* How many times syncing was required to catch up the expected block.
*/
2022-09-05 23:57:11 +03:00
outOfSync: number;
2023-06-02 00:52:58 +03:00
/**
* The number of requests which reported unsupported operation.
*/
2022-09-05 23:57:11 +03:00
unsupportedEvents: number;
2023-06-02 00:52:58 +03:00
/**
* A rolling average (5% current duration) for response time.
*/
2022-09-05 23:57:11 +03:00
rollingDuration: number;
2023-06-02 00:52:58 +03:00
/**
* The ratio of quorum-agreed results to total.
*/
2022-09-05 23:57:11 +03:00
score: number;
}
2022-12-10 09:31:42 +03:00
/**
* Additional options to configure a [[FallbackProvider]].
*/
2023-02-02 12:05:47 +03:00
export type FallbackProviderOptions = {
2022-09-05 23:57:11 +03:00
quorum: number;
eventQuorum: number;
eventWorkers: number;
};
2022-12-10 09:31:42 +03:00
/**
2023-06-02 00:52:58 +03:00
* A **FallbackProvider** manages several [[Providers]] providing
* resiliance by switching between slow or misbehaving nodes, security
* by requiring multiple backends to aggree and performance by allowing
* faster backends to respond earlier.
2022-12-10 09:31:42 +03:00
*
*/
2022-09-05 23:57:11 +03:00
export declare class FallbackProvider extends AbstractProvider {
#private;
2023-06-02 00:52:58 +03:00
/**
* The number of backends that must agree on a value before it is
* accpeted.
*/
2022-09-05 23:57:11 +03:00
readonly quorum: number;
2023-06-02 00:52:58 +03:00
/**
* @_ignore:
*/
2022-09-05 23:57:11 +03:00
readonly eventQuorum: number;
2023-06-02 00:52:58 +03:00
/**
* @_ignore:
*/
2022-09-05 23:57:11 +03:00
readonly eventWorkers: number;
2023-06-02 00:52:58 +03:00
/**
* Creates a new **FallbackProvider** with %%providers%% connected to
* %%network%%.
*
* If a [[Provider]] is included in %%providers%%, defaults are used
* for the configuration.
*/
2022-09-05 23:57:11 +03:00
constructor(providers: Array<AbstractProvider | FallbackProviderConfig>, network?: Networkish);
get providerConfigs(): Array<FallbackProviderState>;
2022-09-27 10:45:27 +03:00
_detectNetwork(): Promise<Network>;
2023-06-02 00:52:58 +03:00
/**
* Transforms a %%req%% into the correct method call on %%provider%%.
*/
2022-11-09 10:57:02 +03:00
_translatePerform(provider: AbstractProvider, req: PerformActionRequest): Promise<any>;
2022-09-05 23:57:11 +03:00
_perform<T = any>(req: PerformActionRequest): Promise<T>;
2022-12-31 00:35:04 +03:00
destroy(): Promise<void>;
2022-09-05 23:57:11 +03:00
}
//# sourceMappingURL=provider-fallback.d.ts.map