Use querystorageAt for map entries (optional) (#2119)
This commit is contained in:
@@ -41,7 +41,7 @@ interface MetaDecoration {
|
||||
type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
|
||||
|
||||
const PAGE_SIZE_KEYS = 256;
|
||||
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS / 2;
|
||||
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -248,6 +248,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
.forEach(([_, { method, section }]): void => {
|
||||
delete (this._rpc as any)[section][method];
|
||||
delete (this._rpcCore as any)[section][method];
|
||||
delete (this._rx.rpc as any)[section][method];
|
||||
});
|
||||
}
|
||||
@@ -502,12 +503,13 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
combineLatest([
|
||||
of(keys),
|
||||
from(Array(Math.ceil(keys.length / PAGE_SIZE_VALS)).fill(0)).pipe(
|
||||
// FIXME New RPC to take care of this in the works...
|
||||
concatMap((_, index): Observable<Option<Raw>[]> =>
|
||||
this._rpcCore.state.subscribeStorage<Option<Raw>[]>(
|
||||
keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS)
|
||||
).pipe(take(1))
|
||||
),
|
||||
concatMap((_, index): Observable<Option<Raw>[]> => {
|
||||
const keyset = keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS);
|
||||
|
||||
return this._rpcCore.state.queryStorageAt
|
||||
? this._rpcCore.state.queryStorageAt<Option<Raw>[]>(keyset)
|
||||
: this._rpcCore.state.subscribeStorage<Option<Raw>[]>(keyset).pipe(take(1));
|
||||
}),
|
||||
toArray(),
|
||||
map((valsArr: Option<Raw>[][]): Option<Raw>[] =>
|
||||
valsArr.reduce((result: Option<Raw>[], vals): Option<Raw>[] =>
|
||||
|
||||
Reference in New Issue
Block a user