@solana/web3.js 1.73.5 → 1.74.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.73.5",
3
+ "version": "1.74.1",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -4739,28 +4739,40 @@ export class Connection {
4739
4739
  /*
4740
4740
  * Returns the current block height of the node
4741
4741
  */
4742
- async getBlockHeight(
4743
- commitmentOrConfig?: Commitment | GetBlockHeightConfig,
4744
- ): Promise<number> {
4745
- const {commitment, config} =
4746
- extractCommitmentFromConfig(commitmentOrConfig);
4747
- const args = this._buildArgs(
4748
- [],
4749
- commitment,
4750
- undefined /* encoding */,
4751
- config,
4752
- );
4753
- const unsafeRes = await this._rpcRequest('getBlockHeight', args);
4754
- const res = create(unsafeRes, jsonRpcResult(number()));
4755
- if ('error' in res) {
4756
- throw new SolanaJSONRPCError(
4757
- res.error,
4758
- 'failed to get block height information',
4742
+ getBlockHeight = (() => {
4743
+ const requestPromises: {[hash: string]: Promise<number>} = {};
4744
+ return async (
4745
+ commitmentOrConfig?: Commitment | GetBlockHeightConfig,
4746
+ ): Promise<number> => {
4747
+ const {commitment, config} =
4748
+ extractCommitmentFromConfig(commitmentOrConfig);
4749
+ const args = this._buildArgs(
4750
+ [],
4751
+ commitment,
4752
+ undefined /* encoding */,
4753
+ config,
4759
4754
  );
4760
- }
4761
-
4762
- return res.result;
4763
- }
4755
+ const requestHash = fastStableStringify(args);
4756
+ requestPromises[requestHash] =
4757
+ requestPromises[requestHash] ??
4758
+ (async () => {
4759
+ try {
4760
+ const unsafeRes = await this._rpcRequest('getBlockHeight', args);
4761
+ const res = create(unsafeRes, jsonRpcResult(number()));
4762
+ if ('error' in res) {
4763
+ throw new SolanaJSONRPCError(
4764
+ res.error,
4765
+ 'failed to get block height information',
4766
+ );
4767
+ }
4768
+ return res.result;
4769
+ } finally {
4770
+ delete requestPromises[requestHash];
4771
+ }
4772
+ })();
4773
+ return await requestPromises[requestHash];
4774
+ };
4775
+ })();
4764
4776
 
4765
4777
  /*
4766
4778
  * Returns recent block production information from the current or previous epoch