@acala-network/chopsticks-core 0.9.5-1 → 0.9.5-2
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.
|
@@ -423,7 +423,6 @@ class Blockchain {
|
|
|
423
423
|
* @param options - Options for instantiating the blockchain
|
|
424
424
|
*/ constructor({ api, buildBlockMode, inherentProvider, db, header, mockSignatureHost = false, allowUnresolvedImports = false, runtimeLogLevel = 0, registeredTypes = {}, offchainWorker = false, maxMemoryBlockCount = 500 }){
|
|
425
425
|
_class_private_method_init(this, _registerBlock);
|
|
426
|
-
_define_property(this, "uid", Math.random().toString(36).substring(2));
|
|
427
426
|
/** API instance, for getting on-chain data. */ _define_property(this, "api", void 0);
|
|
428
427
|
/** Datasource for caching storage and blocks data. */ _define_property(this, "db", void 0);
|
|
429
428
|
/** Enable mock signature. Any signature starts with 0xdeadbeef and filled by 0xcd is considered valid */ _define_property(this, "mockSignatureHost", void 0);
|
|
@@ -36,20 +36,22 @@ function _interop_require_default(obj) {
|
|
|
36
36
|
const logger = _logger.defaultLogger.child({
|
|
37
37
|
module: 'decoder'
|
|
38
38
|
});
|
|
39
|
-
const _CACHE = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!_CACHE[uid]) {
|
|
47
|
-
_CACHE[uid] = createCache();
|
|
39
|
+
const _CACHE = new _lrucache.LRUCache({
|
|
40
|
+
max: 20 /* max 20 registries */
|
|
41
|
+
});
|
|
42
|
+
const getCache = (registry)=>{
|
|
43
|
+
const cache = _CACHE.get(registry);
|
|
44
|
+
if (cache) {
|
|
45
|
+
return cache;
|
|
48
46
|
}
|
|
49
|
-
|
|
47
|
+
const newCache = new _lrucache.LRUCache({
|
|
48
|
+
max: 100 /* max 100 storage entries */
|
|
49
|
+
});
|
|
50
|
+
_CACHE.set(registry, newCache);
|
|
51
|
+
return newCache;
|
|
50
52
|
};
|
|
51
53
|
const getStorageEntry = (meta, key)=>{
|
|
52
|
-
const cache = getCache(meta.registry
|
|
54
|
+
const cache = getCache(meta.registry);
|
|
53
55
|
for (const prefix of cache.keys()){
|
|
54
56
|
if (key.startsWith(prefix)) // update the recency of the cache entry
|
|
55
57
|
return cache.get(prefix);
|
|
@@ -36,7 +36,6 @@ const logger = defaultLogger.child({
|
|
|
36
36
|
* chain.newBlock()
|
|
37
37
|
* ```
|
|
38
38
|
*/ export class Blockchain {
|
|
39
|
-
uid = Math.random().toString(36).substring(2);
|
|
40
39
|
/** API instance, for getting on-chain data. */ api;
|
|
41
40
|
/** Datasource for caching storage and blocks data. */ db;
|
|
42
41
|
/** Enable mock signature. Any signature starts with 0xdeadbeef and filled by 0xcd is considered valid */ mockSignatureHost;
|
|
@@ -7,20 +7,22 @@ import { defaultLogger } from '../logger.js';
|
|
|
7
7
|
const logger = defaultLogger.child({
|
|
8
8
|
module: 'decoder'
|
|
9
9
|
});
|
|
10
|
-
const _CACHE = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!_CACHE[uid]) {
|
|
18
|
-
_CACHE[uid] = createCache();
|
|
10
|
+
const _CACHE = new LRUCache({
|
|
11
|
+
max: 20 /* max 20 registries */
|
|
12
|
+
});
|
|
13
|
+
const getCache = (registry)=>{
|
|
14
|
+
const cache = _CACHE.get(registry);
|
|
15
|
+
if (cache) {
|
|
16
|
+
return cache;
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
const newCache = new LRUCache({
|
|
19
|
+
max: 100 /* max 100 storage entries */
|
|
20
|
+
});
|
|
21
|
+
_CACHE.set(registry, newCache);
|
|
22
|
+
return newCache;
|
|
21
23
|
};
|
|
22
24
|
const getStorageEntry = (meta, key)=>{
|
|
23
|
-
const cache = getCache(meta.registry
|
|
25
|
+
const cache = getCache(meta.registry);
|
|
24
26
|
for (const prefix of cache.keys()){
|
|
25
27
|
if (key.startsWith(prefix)) // update the recency of the cache entry
|
|
26
28
|
return cache.get(prefix);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "0.9.5-
|
|
3
|
+
"version": "0.9.5-2",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"docs:prep": "typedoc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@acala-network/chopsticks-executor": "0.9.5-
|
|
15
|
+
"@acala-network/chopsticks-executor": "0.9.5-2",
|
|
16
16
|
"@polkadot/rpc-provider": "^10.10.1",
|
|
17
17
|
"@polkadot/types": "^10.10.1",
|
|
18
18
|
"@polkadot/types-codec": "^10.10.1",
|