@@ -11,7 +11,7 @@ import type { RpcCoreStats, RpcInterfaceMethod } from './types/index.js';
1111
1212import { Observable , publishReplay , refCount } from 'rxjs' ;
1313
14- import { DEFAULT_CAPACITY , LRUCache } from '@polkadot/rpc-provider' ;
14+ import { LRUCache } from '@polkadot/rpc-provider' ;
1515import { rpcDefinitions } from '@polkadot/types' ;
1616import { hexToU8a , isFunction , isNull , isUndefined , lazyMethod , logger , memoize , objectSpread , u8aConcat , u8aToU8a } from '@polkadot/util' ;
1717
@@ -33,6 +33,7 @@ type MemoizedRpcInterfaceMethod = Memoized<RpcInterfaceMethod> & {
3333interface Options {
3434 isPedantic ?: boolean ;
3535 provider : ProviderInterface ;
36+ rpcCacheCapacity ?: number ;
3637 userRpc ?: Record < string , Record < string , DefinitionRpc | DefinitionRpcSub > > ;
3738}
3839
@@ -47,6 +48,8 @@ const EMPTY_META = {
4748 }
4849} ;
4950
51+ const RPC_CORE_DEFAULT_CAPACITY = 1024 * 10 * 10 ;
52+
5053// utility method to create a nicely-formatted error
5154/** @internal */
5255function logErrorMessage ( method : string , { noErrorLog, params, type } : DefinitionRpc , error : Error ) : void {
@@ -109,7 +112,7 @@ export class RpcCore {
109112 * Default constructor for the core RPC handler
110113 * @param {ProviderInterface } provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
111114 */
112- constructor ( instanceId : string , registry : Registry , { isPedantic = true , provider, userRpc = { } } : Options ) {
115+ constructor ( instanceId : string , registry : Registry , { isPedantic = true , provider, rpcCacheCapacity , userRpc = { } } : Options ) {
113116 if ( ! provider || ! isFunction ( provider . send ) ) {
114117 throw new Error ( 'Expected Provider to API create' ) ;
115118 }
@@ -123,7 +126,7 @@ export class RpcCore {
123126
124127 // these are the base keys (i.e. part of jsonrpc)
125128 this . sections . push ( ...sectionNames ) ;
126- this . #storageCache = new LRUCache ( DEFAULT_CAPACITY * 10 * 10 ) ;
129+ this . #storageCache = new LRUCache ( rpcCacheCapacity || RPC_CORE_DEFAULT_CAPACITY ) ;
127130 // decorate all interfaces, defined and user on this instance
128131 this . addUserInterfaces ( userRpc ) ;
129132 }
0 commit comments