-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5186114
commit f8e2ed2
Showing
5 changed files
with
88 additions
and
255 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
diff --git a/http/index.js b/http/index.js | ||
index 63d7d0439956851f8794e10defbbd944fdae2766..13a08f7451bcb5838b19a64d47182a1dd8a7a813 100644 | ||
--- a/http/index.js | ||
+++ b/http/index.js | ||
@@ -1,4 +1,4 @@ | ||
-import { logger, noop } from '@polkadot/util'; | ||
+import { logger, noop, stringify } from '@polkadot/util'; | ||
import { fetch } from '@polkadot/x-fetch'; | ||
import { RpcCoder } from '../coder/index.js'; | ||
import defaults from '../defaults.js'; | ||
@@ -99,13 +99,14 @@ export class HttpProvider { | ||
async send(method, params, isCacheable) { | ||
this.__internal__stats.total.requests++; | ||
const [, body] = this.__internal__coder.encodeJson(method, params); | ||
+ const cacheKey = isCacheable ? `${method}::${stringify(params)}` : ''; | ||
let resultPromise = isCacheable | ||
- ? this.__internal__callCache.get(body) | ||
+ ? this.__internal__callCache.get(cacheKey) | ||
: null; | ||
if (!resultPromise) { | ||
resultPromise = this.__internal__send(body); | ||
if (isCacheable) { | ||
- this.__internal__callCache.set(body, resultPromise); | ||
+ this.__internal__callCache.set(cacheKey, resultPromise); | ||
} | ||
} | ||
else { | ||
diff --git a/ws/index.js b/ws/index.js | ||
index 879299b5d960a9bce6572a0e585ede29935db2a7..9ea7f184dd0c65dfe37585dd811120838ca580b9 100644 | ||
--- a/ws/index.js | ||
+++ b/ws/index.js | ||
@@ -1,5 +1,5 @@ | ||
import { EventEmitter } from 'eventemitter3'; | ||
-import { isChildClass, isNull, isUndefined, logger, noop, objectSpread } from '@polkadot/util'; | ||
+import { isChildClass, isNull, isUndefined, logger, noop, objectSpread, stringify } from '@polkadot/util'; | ||
import { xglobal } from '@polkadot/x-global'; | ||
import { WebSocket } from '@polkadot/x-ws'; | ||
import { RpcCoder } from '../coder/index.js'; | ||
@@ -395,13 +395,14 @@ export class WsProvider { | ||
this.__internal__endpointStats.requests++; | ||
this.__internal__stats.total.requests++; | ||
const [id, body] = this.__internal__coder.encodeJson(method, params); | ||
+ const cacheKey = isCacheable ? `${method}::${stringify(params)}` : ''; | ||
let resultPromise = isCacheable | ||
- ? this.__internal__callCache.get(body) | ||
+ ? this.__internal__callCache.get(cacheKey) | ||
: null; | ||
if (!resultPromise) { | ||
resultPromise = this.__internal__send(id, body, method, params, subscription); | ||
if (isCacheable) { | ||
- this.__internal__callCache.set(body, resultPromise); | ||
+ this.__internal__callCache.set(cacheKey, resultPromise); | ||
} | ||
} | ||
else { |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.