File tree Expand file tree Collapse file tree 4 files changed +30
-12
lines changed Expand file tree Collapse file tree 4 files changed +30
-12
lines changed Original file line number Diff line number Diff line change 1
1
import { ApiPromise , WsProvider } from '@polkadot/api' ;
2
- import { withAcalaTypes } from '@acala-network/api ' ;
2
+ import { acalaTypesBundle } from '@acala-network/types ' ;
3
3
4
4
import { BaseProvider , BaseProviderOptions } from './base-provider' ;
5
5
6
+ export type EvmRpcProviderOptions = BaseProviderOptions & {
7
+ rpcCacheCapacity ?: number ;
8
+ } ;
9
+
6
10
export class EvmRpcProvider extends BaseProvider {
7
- constructor ( endpoint : string | string [ ] , opts ?: BaseProviderOptions ) {
11
+ constructor ( endpoint : string | string [ ] , opts ?: EvmRpcProviderOptions ) {
8
12
super ( opts ) ;
9
13
10
- const api = new ApiPromise ( withAcalaTypes ( {
14
+ const api = new ApiPromise ( {
11
15
provider : new WsProvider ( endpoint ) ,
12
- } ) ) ;
16
+ typesBundle : acalaTypesBundle ,
17
+ rpcCacheCapacity : opts ?. rpcCacheCapacity ,
18
+ } ) ;
13
19
14
20
this . setApi ( api ) ;
15
21
}
16
22
17
- static from ( endpoint : string | string [ ] , opt ?: BaseProviderOptions ) : EvmRpcProvider {
23
+ static from ( endpoint : string | string [ ] , opt ?: EvmRpcProviderOptions ) : EvmRpcProvider {
18
24
return new EvmRpcProvider ( endpoint , opt ) ;
19
25
}
20
26
}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export async function start(): Promise<void> {
18
18
subqlUrl : opts . subqlUrl ,
19
19
maxBlockCacheSize : opts . maxBlockCacheSize ,
20
20
storageCacheSize : opts . storageCacheSize ,
21
+ rpcCacheCapacity : opts . rpcCacheCapacity ,
21
22
} ) ;
22
23
23
24
const bridge = new Eip1193Bridge ( provider ) ;
@@ -58,8 +59,9 @@ export async function start(): Promise<void> {
58
59
server host : ${ opts . host }
59
60
server port : ${ opts . port }
60
61
max blockCache : ${ opts . maxBlockCacheSize }
61
- max batchSize : ${ opts . maxBatchSize }
62
+ max batchSize : ${ opts . maxBatchSize }
62
63
max storageSize : ${ opts . storageCacheSize }
64
+ cache capacity : ${ opts . rpcCacheCapacity }
63
65
safe mode : ${ opts . safeMode }
64
66
local mode : ${ opts . localMode }
65
67
http only : ${ opts . httpOnly }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const {
11
11
MAX_CACHE_SIZE ,
12
12
MAX_BATCH_SIZE ,
13
13
STORAGE_CACHE_SIZE ,
14
+ RPC_CACHE_CAPACITY ,
14
15
SAFE_MODE ,
15
16
LOCAL_MODE ,
16
17
HTTP_ONLY ,
@@ -76,6 +77,12 @@ export const yargsOptions = yargs(hideBin(process.argv))
76
77
describe : 'max storage cache size' ,
77
78
type : 'number' ,
78
79
} ,
80
+ rpcCacheCapacity : {
81
+ demandOption : false ,
82
+ default : Number ( RPC_CACHE_CAPACITY ?? 1000 ) ,
83
+ describe : 'polkadot api rpc cache capacity' ,
84
+ type : 'number' ,
85
+ } ,
79
86
safeMode : {
80
87
alias : 's' ,
81
88
demandOption : false ,
Original file line number Diff line number Diff line change 1
1
import { ApiPromise , WsProvider } from '@polkadot/api' ;
2
- import { BaseProvider , BaseProviderOptions } from '@acala-network/eth-providers/base-provider' ;
3
- import { withAcalaTypes } from '@acala-network/api' ;
2
+ import { BaseProvider } from '@acala-network/eth-providers/base-provider' ;
3
+ import { EvmRpcProviderOptions } from '@acala-network/eth-providers' ;
4
+ import { acalaTypesBundle } from '@acala-network/types' ;
4
5
import tracer from 'dd-trace' ;
5
6
6
7
const TRACE_METHODS = [
@@ -78,17 +79,19 @@ export class BaseProviderWithTrace extends BaseProvider {
78
79
}
79
80
80
81
export class EvmRpcProviderWithTrace extends BaseProviderWithTrace {
81
- constructor ( endpoint : string | string [ ] , opts ?: BaseProviderOptions ) {
82
+ constructor ( endpoint : string | string [ ] , opts ?: EvmRpcProviderOptions ) {
82
83
super ( opts ) ;
83
84
84
- const api = new ApiPromise ( withAcalaTypes ( {
85
+ const api = new ApiPromise ( {
85
86
provider : new WsProvider ( endpoint ) ,
86
- } ) ) ;
87
+ typesBundle : acalaTypesBundle ,
88
+ rpcCacheCapacity : opts ?. rpcCacheCapacity ,
89
+ } ) ;
87
90
88
91
this . setApi ( api ) ;
89
92
}
90
93
91
- static from ( endpoint : string | string [ ] , opt ?: BaseProviderOptions ) : EvmRpcProviderWithTrace {
94
+ static from ( endpoint : string | string [ ] , opt ?: EvmRpcProviderOptions ) : EvmRpcProviderWithTrace {
92
95
return new EvmRpcProviderWithTrace ( endpoint , opt ) ;
93
96
}
94
97
}
You can’t perform that action at this time.
0 commit comments