Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit interval time & condition while connecting #1103

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/rmb_direct_client/lib/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Keyring } from "@polkadot/api";
import { ApiPromise, WsProvider } from "@polkadot/api";
import { KeyringPair } from "@polkadot/keyring/types";
import { KeypairType } from "@polkadot/util-crypto/types";
import { waitReady } from "@polkadot/wasm-crypto";
Expand Down Expand Up @@ -173,15 +172,15 @@ class Client {
}
waitForOpenConnection() {
return new Promise((resolve, reject) => {
const maxNumberOfAttempts = 10;
const intervalTime = 300; //ms
const maxNumberOfAttempts = 20;
const intervalTime = 500; //ms

let currentAttempt = 0;
const interval = setInterval(() => {
if (currentAttempt > maxNumberOfAttempts - 1) {
clearInterval(interval);
reject(new Error({ message: "Maximum number of attempts exceeded" }));
} else if (this.con.readyState === this.con.OPEN) {
} else if (this.con && this.con.readyState === this.con.OPEN) {
clearInterval(interval);
resolve("connected");
}
Expand Down
Loading