*Add a max retry limit
This commit is contained in:
parent
12db0806a8
commit
2a7fa853c9
|
@ -15,6 +15,8 @@ export default class RpcQuery {
|
|||
private _completed: boolean = false;
|
||||
private _responses: { [relay: string]: RPCResponse } = {};
|
||||
private _promiseResolve?: (data: any) => void;
|
||||
private _maxTries = 3;
|
||||
private _tries = 0;
|
||||
|
||||
constructor(network: RpcNetwork, query: RPCRequest) {
|
||||
this._network = network;
|
||||
|
@ -131,14 +133,19 @@ export default class RpcQuery {
|
|||
this._network.majorityThreshold
|
||||
) {
|
||||
// @ts-ignore
|
||||
const response: RPCResponse = responseObjects[responseHash];
|
||||
let response: RPCResponse | boolean = responseObjects[responseHash];
|
||||
|
||||
// @ts-ignore
|
||||
if (null === response) {
|
||||
if (this._tries <= this._maxTries) {
|
||||
this._tries++;
|
||||
this.retry();
|
||||
return;
|
||||
}
|
||||
|
||||
response = false;
|
||||
}
|
||||
|
||||
this.resolve(response);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue