Skip to content

Commit

Permalink
fix: edit rpcBatch whitelist logic error (#3000)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwang1113 authored May 21, 2023
1 parent c913c10 commit 1a78c5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class SimpleDbEntitySetting extends SimpleDbEntityBase<ISimpleDbEntitySet
rawData?.rpcBatchWhitelists?.filter((t) => t.type === 'custom') ?? [];
return this.setRawData({
...rawData,
rpcBatchWhitelists: values?.concat(customWhitelist) ?? [],
rpcBatchWhitelists: (values ?? []).concat(customWhitelist),
});
}

Expand All @@ -136,7 +136,7 @@ export class SimpleDbEntitySetting extends SimpleDbEntityBase<ISimpleDbEntitySet
...rawData,
rpcBatchWhitelists:
rawData?.rpcBatchWhitelists?.filter(
(n) => n.url !== value && n.type === 'custom',
(n) => n.url !== value || n.type !== 'custom',
) ?? [],
});
}
Expand Down
12 changes: 6 additions & 6 deletions packages/kit-bg/src/services/ServiceNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,6 @@ class ServiceNetwork extends ServiceBase {
};
const network = await engine.getNetwork(networkId);
const url = network.rpcURL;
const whitelistHosts =
await simpleDb.setting.getRpcBatchFallbackWhitelistHosts();

const item = whitelistHosts.find((n) => url.includes(n.url));
const isRpcInWhitelistHost = !!item;

try {
if (networkId.startsWith(IMPL_EVM)) {
const vault = await engine.getChainOnlyVault(networkId);
Expand All @@ -381,6 +375,12 @@ class ServiceNetwork extends ServiceBase {
}

if (networkId.startsWith(IMPL_EVM)) {
const whitelistHosts =
await simpleDb.setting.getRpcBatchFallbackWhitelistHosts();

const item = whitelistHosts.find((n) => url.includes(n.url));
const isRpcInWhitelistHost = !!item;

const ts = rpcUrlSupportBatchCheckTimestampMap.get(url);
if (status.rpcBatchSupported === false && !isRpcInWhitelistHost) {
if (!ts || Date.now() - ts > getTimeDurationMs({ day: 1 })) {
Expand Down

0 comments on commit 1a78c5b

Please sign in to comment.