From 2820cd69be267a105d420dfa103b6832a0cd9c94 Mon Sep 17 00:00:00 2001 From: Thor <109517311+swimthor@users.noreply.github.com> Date: Sun, 9 Oct 2022 21:35:09 +0100 Subject: [PATCH] refactor(solana): remove dummy ws connection in SolanaClient --- packages/solana/src/client.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/solana/src/client.ts b/packages/solana/src/client.ts index 2f9dfdbaa..c961b21b3 100644 --- a/packages/solana/src/client.ts +++ b/packages/solana/src/client.ts @@ -160,11 +160,6 @@ export class SolanaClient extends Client< private readonly parsedTxCache: Map; private rpcIndex: number; private readonly endpoints: readonly string[]; - // TODO: Check if this is still necessary. - // The websocket library solana/web3.js closes its websocket connection when the subscription list - // is empty after opening its first time, preventing subsequent subscriptions from receiving responses. - // This is a hack to prevent the list from ever getting empty - private dummySubscriptionId?: number; public constructor( chainConfig: SolanaChainConfig, @@ -623,22 +618,12 @@ export class SolanaClient extends Client< // and it is not being called in the constructor (when this.connection is still undefined) return; } - if (this.dummySubscriptionId !== undefined) { - // Remove old dummy subscription if it has been initialized. - this.connection - .removeAccountChangeListener(this.dummySubscriptionId) - .catch(console.error); - } this.rpcIndex = (this.rpcIndex + 1) % this.endpoints.length; this.connection = new CustomConnection(this.endpoints[this.rpcIndex], { commitment: DEFAULT_COMMITMENT_LEVEL, confirmTransactionInitialTimeout: 60 * 1000, disableRetryOnRateLimit: true, }); - this.dummySubscriptionId = this.connection.onAccountChange( - Keypair.generate().publicKey, - () => {}, - ); } // Looks for a signature, only returns a value if there's no error