@polkadot/rpc-core 10.9.1 → 10.10.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/bundle.d.ts +5 -0
- package/bundle.js +19 -1
- package/cjs/bundle.js +19 -1
- package/cjs/packageInfo.js +1 -1
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/types/base.d.ts +11 -0
package/bundle.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
2
2
|
import type { AnyNumber, DefinitionRpc, DefinitionRpcExt, DefinitionRpcSub, Registry } from '@polkadot/types/types';
|
|
3
|
+
import type { RpcCoreStats } from './types/index.js';
|
|
3
4
|
export { packageInfo } from './packageInfo.js';
|
|
4
5
|
export * from './util/index.js';
|
|
5
6
|
interface Options {
|
|
@@ -53,6 +54,10 @@ export declare class RpcCore {
|
|
|
53
54
|
* @description Manually disconnect from the attached provider
|
|
54
55
|
*/
|
|
55
56
|
disconnect(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @description Returns the underlying core stats, including those from teh provider
|
|
59
|
+
*/
|
|
60
|
+
get stats(): RpcCoreStats | undefined;
|
|
56
61
|
/**
|
|
57
62
|
* @description Sets a registry swap (typically from Api)
|
|
58
63
|
*/
|
package/bundle.js
CHANGED
|
@@ -56,9 +56,10 @@ export class RpcCore {
|
|
|
56
56
|
*/
|
|
57
57
|
constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
|
|
58
58
|
this.__internal__storageCache = new Map();
|
|
59
|
+
this.__internal__storageCacheHits = 0;
|
|
60
|
+
this.__internal__storageCacheSize = 0;
|
|
59
61
|
this.mapping = new Map();
|
|
60
62
|
this.sections = [];
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
62
63
|
if (!provider || !isFunction(provider.send)) {
|
|
63
64
|
throw new Error('Expected Provider to API create');
|
|
64
65
|
}
|
|
@@ -90,6 +91,21 @@ export class RpcCore {
|
|
|
90
91
|
disconnect() {
|
|
91
92
|
return this.provider.disconnect();
|
|
92
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* @description Returns the underlying core stats, including those from teh provider
|
|
96
|
+
*/
|
|
97
|
+
get stats() {
|
|
98
|
+
const stats = this.provider.stats;
|
|
99
|
+
return stats
|
|
100
|
+
? {
|
|
101
|
+
...stats,
|
|
102
|
+
core: {
|
|
103
|
+
cacheHits: this.__internal__storageCacheHits,
|
|
104
|
+
cacheSize: this.__internal__storageCacheSize
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
: undefined;
|
|
108
|
+
}
|
|
93
109
|
/**
|
|
94
110
|
* @description Sets a registry swap (typically from Api)
|
|
95
111
|
*/
|
|
@@ -337,6 +353,7 @@ export class RpcCore {
|
|
|
337
353
|
if (isNotFound && withCache) {
|
|
338
354
|
const cached = this.__internal__storageCache.get(hexKey);
|
|
339
355
|
if (cached) {
|
|
356
|
+
this.__internal__storageCacheHits++;
|
|
340
357
|
return cached;
|
|
341
358
|
}
|
|
342
359
|
}
|
|
@@ -352,6 +369,7 @@ export class RpcCore {
|
|
|
352
369
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
353
370
|
// will increase memory beyond what is allowed.
|
|
354
371
|
this.__internal__storageCache.set(hexKey, codec);
|
|
372
|
+
this.__internal__storageCacheSize++;
|
|
355
373
|
return codec;
|
|
356
374
|
}
|
|
357
375
|
_newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
|
package/cjs/bundle.js
CHANGED
|
@@ -61,9 +61,10 @@ class RpcCore {
|
|
|
61
61
|
*/
|
|
62
62
|
constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
|
|
63
63
|
this.__internal__storageCache = new Map();
|
|
64
|
+
this.__internal__storageCacheHits = 0;
|
|
65
|
+
this.__internal__storageCacheSize = 0;
|
|
64
66
|
this.mapping = new Map();
|
|
65
67
|
this.sections = [];
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
67
68
|
if (!provider || !(0, util_1.isFunction)(provider.send)) {
|
|
68
69
|
throw new Error('Expected Provider to API create');
|
|
69
70
|
}
|
|
@@ -95,6 +96,21 @@ class RpcCore {
|
|
|
95
96
|
disconnect() {
|
|
96
97
|
return this.provider.disconnect();
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* @description Returns the underlying core stats, including those from teh provider
|
|
101
|
+
*/
|
|
102
|
+
get stats() {
|
|
103
|
+
const stats = this.provider.stats;
|
|
104
|
+
return stats
|
|
105
|
+
? {
|
|
106
|
+
...stats,
|
|
107
|
+
core: {
|
|
108
|
+
cacheHits: this.__internal__storageCacheHits,
|
|
109
|
+
cacheSize: this.__internal__storageCacheSize
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
: undefined;
|
|
113
|
+
}
|
|
98
114
|
/**
|
|
99
115
|
* @description Sets a registry swap (typically from Api)
|
|
100
116
|
*/
|
|
@@ -342,6 +358,7 @@ class RpcCore {
|
|
|
342
358
|
if (isNotFound && withCache) {
|
|
343
359
|
const cached = this.__internal__storageCache.get(hexKey);
|
|
344
360
|
if (cached) {
|
|
361
|
+
this.__internal__storageCacheHits++;
|
|
345
362
|
return cached;
|
|
346
363
|
}
|
|
347
364
|
}
|
|
@@ -357,6 +374,7 @@ class RpcCore {
|
|
|
357
374
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
358
375
|
// will increase memory beyond what is allowed.
|
|
359
376
|
this.__internal__storageCache.set(hexKey, codec);
|
|
377
|
+
this.__internal__storageCacheSize++;
|
|
360
378
|
return codec;
|
|
361
379
|
}
|
|
362
380
|
_newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/rpc-core', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.10.1' };
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/detectPackage.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "10.
|
|
21
|
+
"version": "10.10.1",
|
|
22
22
|
"main": "./cjs/index.js",
|
|
23
23
|
"module": "./index.js",
|
|
24
24
|
"types": "./index.d.ts",
|
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@polkadot/rpc-augment": "10.
|
|
113
|
-
"@polkadot/rpc-provider": "10.
|
|
114
|
-
"@polkadot/types": "10.
|
|
115
|
-
"@polkadot/util": "^12.
|
|
112
|
+
"@polkadot/rpc-augment": "10.10.1",
|
|
113
|
+
"@polkadot/rpc-provider": "10.10.1",
|
|
114
|
+
"@polkadot/types": "10.10.1",
|
|
115
|
+
"@polkadot/util": "^12.5.1",
|
|
116
116
|
"rxjs": "^7.8.1",
|
|
117
|
-
"tslib": "^2.
|
|
117
|
+
"tslib": "^2.6.2"
|
|
118
118
|
}
|
|
119
119
|
}
|
package/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@polkadot/rpc-core', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.
|
|
1
|
+
export const packageInfo = { name: '@polkadot/rpc-core', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.10.1' };
|
package/types/base.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
|
+
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
|
2
3
|
import type { AnyFunction, Codec, DefinitionRpc } from '@polkadot/types/types';
|
|
3
4
|
export interface RpcInterfaceMethod {
|
|
4
5
|
<T extends Codec>(...params: unknown[]): Observable<T>;
|
|
@@ -9,3 +10,13 @@ export type AugmentedRpc<F extends AnyFunction> = F & {
|
|
|
9
10
|
raw: <T>(...params: Parameters<F>) => Observable<T>;
|
|
10
11
|
meta: DefinitionRpc;
|
|
11
12
|
};
|
|
13
|
+
/** Stats from the rpc-core layer, including the provider stats */
|
|
14
|
+
export interface RpcCoreStats extends NonNullable<ProviderInterface['stats']> {
|
|
15
|
+
/** Internal stats for the rpc-core layer */
|
|
16
|
+
core: {
|
|
17
|
+
/** The number of values retrieved from the core cache */
|
|
18
|
+
cacheHits: number;
|
|
19
|
+
/** The number of entries in the core cache */
|
|
20
|
+
cacheSize: number;
|
|
21
|
+
};
|
|
22
|
+
}
|