Skip to content

Commit

Permalink
refactor(solana): remove dummy ws connection in SolanaClient
Browse files Browse the repository at this point in the history
  • Loading branch information
swimthor committed Oct 26, 2022
1 parent 622e9d8 commit 2820cd6
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions packages/solana/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ export class SolanaClient extends Client<
private readonly parsedTxCache: Map<string, ParsedTransactionWithMeta>;
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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2820cd6

Please sign in to comment.