Adjust LRU historic size (clarify isCachable flag) (#4419)

This commit is contained in:
Jaco
2022-01-06 09:31:13 +02:00
committed by GitHub
parent 3a6c4a524a
commit 392d447b99
4 changed files with 14 additions and 1 deletions
+2
View File
@@ -204,6 +204,8 @@ export class RpcCore {
? await this.#getBlockRegistry(u8aToU8a(blockHash))
: { registry: this.#registryDefault };
const params = this._formatInputs(registry, null, def, values);
// only cache .at(<blockHash>) queries, e.g. where valid blockHash was supplied
const result = await this.provider.send<AnyJson>(rpcName, params.map((p) => p.toJSON()), !!blockHash);
return this._formatResult(isScale, registry, blockHash, method, def, params, result);
+4 -1
View File
@@ -1,7 +1,10 @@
// Copyright 2017-2022 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0
const DEFAULT_CAPACITY = 2048;
// Assuming all 1.5MB responses, we apply a default allowing for 576MB
// cache space (depending on the historic queries this would vary, metadata
// for Kusama/Polkadot/Substrate falls between 600-750K, 2x for estimate)
const DEFAULT_CAPACITY = 384;
class LRUNode {
public readonly key: string;
+1
View File
@@ -328,6 +328,7 @@ export class WsProvider implements ProviderInterface {
* ```
*/
public subscribe (type: string, method: string, params: unknown[], callback: ProviderInterfaceCallback): Promise<number | string> {
// subscriptions are not cached, LRU applies to .at(<blockHash>) only
return this.send<number | string>(method, params, false, { callback, type });
}