diff options
Diffstat (limited to 'packages/subproviders/src/subproviders/redundant_rpc.ts')
-rw-r--r-- | packages/subproviders/src/subproviders/redundant_rpc.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/subproviders/src/subproviders/redundant_rpc.ts b/packages/subproviders/src/subproviders/redundant_rpc.ts index dacd1c2c5..2b84d223b 100644 --- a/packages/subproviders/src/subproviders/redundant_rpc.ts +++ b/packages/subproviders/src/subproviders/redundant_rpc.ts @@ -7,6 +7,11 @@ import { Callback } from '../types'; import { Subprovider } from './subprovider'; +/** + * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. + * It attempts to handle each JSON RPC request by sequentially attempting to receive a valid response from one of a + * set of JSON RPC endpoints. + */ export class RedundantRPCSubprovider extends Subprovider { private _rpcs: RpcSubprovider[]; private static async _firstSuccessAsync( @@ -28,6 +33,10 @@ export class RedundantRPCSubprovider extends Subprovider { throw lastErr; } } + /** + * Instantiates a new RedundantRPCSubprovider + * @param endpoints JSON RPC endpoints to attempt. Attempts are made in the order of the endpoints. + */ constructor(endpoints: string[]) { super(); this._rpcs = _.map(endpoints, endpoint => { @@ -37,8 +46,8 @@ export class RedundantRPCSubprovider extends Subprovider { }); } // Required to implement this public interface which doesn't conform to our linting rule. - // tslint:disable-next-line:async-suffix - public async handleRequest( + // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected + private async handleRequest( payload: Web3.JSONRPCRequestPayload, next: Callback, end: (err: Error | null, data?: any) => void, |