@polkadot/rpc-core 10.9.1 → 10.11.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 +28 -4
- package/cjs/bundle.js +28 -4
- package/cjs/packageInfo.js +1 -1
- package/package.json +7 -7
- 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
|
@@ -49,16 +49,23 @@ function isTreatAsHex(key) {
|
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
51
|
export class RpcCore {
|
|
52
|
+
__internal__instanceId;
|
|
53
|
+
__internal__isPedantic;
|
|
54
|
+
__internal__registryDefault;
|
|
55
|
+
__internal__storageCache = new Map();
|
|
56
|
+
__internal__storageCacheHits = 0;
|
|
57
|
+
__internal__storageCacheSize = 0;
|
|
58
|
+
__internal__getBlockRegistry;
|
|
59
|
+
__internal__getBlockHash;
|
|
60
|
+
mapping = new Map();
|
|
61
|
+
provider;
|
|
62
|
+
sections = [];
|
|
52
63
|
/**
|
|
53
64
|
* @constructor
|
|
54
65
|
* Default constructor for the core RPC handler
|
|
55
66
|
* @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
|
|
56
67
|
*/
|
|
57
68
|
constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
|
|
58
|
-
this.__internal__storageCache = new Map();
|
|
59
|
-
this.mapping = new Map();
|
|
60
|
-
this.sections = [];
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
62
69
|
if (!provider || !isFunction(provider.send)) {
|
|
63
70
|
throw new Error('Expected Provider to API create');
|
|
64
71
|
}
|
|
@@ -90,6 +97,21 @@ export class RpcCore {
|
|
|
90
97
|
disconnect() {
|
|
91
98
|
return this.provider.disconnect();
|
|
92
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* @description Returns the underlying core stats, including those from teh provider
|
|
102
|
+
*/
|
|
103
|
+
get stats() {
|
|
104
|
+
const stats = this.provider.stats;
|
|
105
|
+
return stats
|
|
106
|
+
? {
|
|
107
|
+
...stats,
|
|
108
|
+
core: {
|
|
109
|
+
cacheHits: this.__internal__storageCacheHits,
|
|
110
|
+
cacheSize: this.__internal__storageCacheSize
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
: undefined;
|
|
114
|
+
}
|
|
93
115
|
/**
|
|
94
116
|
* @description Sets a registry swap (typically from Api)
|
|
95
117
|
*/
|
|
@@ -337,6 +359,7 @@ export class RpcCore {
|
|
|
337
359
|
if (isNotFound && withCache) {
|
|
338
360
|
const cached = this.__internal__storageCache.get(hexKey);
|
|
339
361
|
if (cached) {
|
|
362
|
+
this.__internal__storageCacheHits++;
|
|
340
363
|
return cached;
|
|
341
364
|
}
|
|
342
365
|
}
|
|
@@ -352,6 +375,7 @@ export class RpcCore {
|
|
|
352
375
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
353
376
|
// will increase memory beyond what is allowed.
|
|
354
377
|
this.__internal__storageCache.set(hexKey, codec);
|
|
378
|
+
this.__internal__storageCacheSize++;
|
|
355
379
|
return codec;
|
|
356
380
|
}
|
|
357
381
|
_newType(registry, blockHash, key, input, isEmpty, entryIndex = -1) {
|
package/cjs/bundle.js
CHANGED
|
@@ -54,16 +54,23 @@ function isTreatAsHex(key) {
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
class RpcCore {
|
|
57
|
+
__internal__instanceId;
|
|
58
|
+
__internal__isPedantic;
|
|
59
|
+
__internal__registryDefault;
|
|
60
|
+
__internal__storageCache = new Map();
|
|
61
|
+
__internal__storageCacheHits = 0;
|
|
62
|
+
__internal__storageCacheSize = 0;
|
|
63
|
+
__internal__getBlockRegistry;
|
|
64
|
+
__internal__getBlockHash;
|
|
65
|
+
mapping = new Map();
|
|
66
|
+
provider;
|
|
67
|
+
sections = [];
|
|
57
68
|
/**
|
|
58
69
|
* @constructor
|
|
59
70
|
* Default constructor for the core RPC handler
|
|
60
71
|
* @param {ProviderInterface} provider An API provider using any of the supported providers (HTTP, SC or WebSocket)
|
|
61
72
|
*/
|
|
62
73
|
constructor(instanceId, registry, { isPedantic = true, provider, userRpc = {} }) {
|
|
63
|
-
this.__internal__storageCache = new Map();
|
|
64
|
-
this.mapping = new Map();
|
|
65
|
-
this.sections = [];
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
67
74
|
if (!provider || !(0, util_1.isFunction)(provider.send)) {
|
|
68
75
|
throw new Error('Expected Provider to API create');
|
|
69
76
|
}
|
|
@@ -95,6 +102,21 @@ class RpcCore {
|
|
|
95
102
|
disconnect() {
|
|
96
103
|
return this.provider.disconnect();
|
|
97
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* @description Returns the underlying core stats, including those from teh provider
|
|
107
|
+
*/
|
|
108
|
+
get stats() {
|
|
109
|
+
const stats = this.provider.stats;
|
|
110
|
+
return stats
|
|
111
|
+
? {
|
|
112
|
+
...stats,
|
|
113
|
+
core: {
|
|
114
|
+
cacheHits: this.__internal__storageCacheHits,
|
|
115
|
+
cacheSize: this.__internal__storageCacheSize
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
: undefined;
|
|
119
|
+
}
|
|
98
120
|
/**
|
|
99
121
|
* @description Sets a registry swap (typically from Api)
|
|
100
122
|
*/
|
|
@@ -342,6 +364,7 @@ class RpcCore {
|
|
|
342
364
|
if (isNotFound && withCache) {
|
|
343
365
|
const cached = this.__internal__storageCache.get(hexKey);
|
|
344
366
|
if (cached) {
|
|
367
|
+
this.__internal__storageCacheHits++;
|
|
345
368
|
return cached;
|
|
346
369
|
}
|
|
347
370
|
}
|
|
@@ -357,6 +380,7 @@ class RpcCore {
|
|
|
357
380
|
// clearing of it, so very long running processes (not just a couple of hours, longer)
|
|
358
381
|
// will increase memory beyond what is allowed.
|
|
359
382
|
this.__internal__storageCache.set(hexKey, codec);
|
|
383
|
+
this.__internal__storageCacheSize++;
|
|
360
384
|
return codec;
|
|
361
385
|
}
|
|
362
386
|
_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.11.1' };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
|
4
4
|
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=18"
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
|
9
9
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/detectPackage.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "10.
|
|
21
|
+
"version": "10.11.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.11.1",
|
|
113
|
+
"@polkadot/rpc-provider": "10.11.1",
|
|
114
|
+
"@polkadot/types": "10.11.1",
|
|
115
|
+
"@polkadot/util": "^12.6.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.11.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
|
+
}
|