Skip to content

Commit 640dd7e

Browse files
committed
fix: display a message if the external node is not running with --indexer
1 parent 7f3bc48 commit 640dd7e

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

packages/neuron-ui/src/containers/Navbar/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ const Navbar = () => {
116116
}, [i18n.language])
117117

118118
useEffect(() => {
119+
if (verifyCkbResult && !verifyCkbResult.withIndexer) {
120+
showGlobalAlertDialog({
121+
type: 'warning',
122+
message: t('navbar.ckb-without-indexer'),
123+
action: 'ok',
124+
})(dispatch)
125+
return
126+
}
127+
119128
// isUpdated is true or version is not empty means check update has return
120129
if (!verifyCkbResult || (isUpdated !== true && !version)) {
121130
return
@@ -142,12 +151,6 @@ const Navbar = () => {
142151
),
143152
action: 'ok',
144153
})(dispatch)
145-
} else if (!verifyCkbResult.withIndexer) {
146-
showGlobalAlertDialog({
147-
type: 'warning',
148-
message: t('navbar.ckb-without-indexer'),
149-
action: 'ok',
150-
})(dispatch)
151154
}
152155
}, [verifyCkbResult, version, isUpdated])
153156

packages/neuron-wallet/src/block-sync-renderer/sync/full-synchronizer.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ export default class FullSynchronizer extends Synchronizer {
2626
}
2727

2828
private async initSync() {
29-
await this.processNextBlockNumber()
29+
try {
30+
await this.processNextBlockNumber()
3031

31-
while (this.pollingIndexer) {
32-
const indexerTipBlock = await this.indexer.tip()
33-
await this.synchronize(indexerTipBlock)
34-
await CommonUtils.sleep(5000)
32+
while (this.pollingIndexer) {
33+
const indexerTipBlock = await this.indexer.tip()
34+
await this.synchronize(indexerTipBlock)
35+
await CommonUtils.sleep(5000)
36+
}
37+
} catch (error) {
38+
logger.error(`Error connecting to Indexer: ${error.message}`)
3539
}
3640
}
3741

3842
public async connect() {
39-
try {
40-
this.pollingIndexer = true
43+
this.pollingIndexer = true
4144

42-
this.initSync()
43-
} catch (error) {
44-
logger.error(`Error connecting to Indexer: ${error.message}`)
45-
throw error
46-
}
45+
this.initSync()
4746
}
4847

4948
async processTxsInNextBlockNumber() {

packages/neuron-wallet/src/block-sync-renderer/sync/light-synchronizer.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,18 @@ export default class LightSynchronizer extends Synchronizer {
280280
}
281281

282282
private async initSync(syncMultisig?: boolean) {
283-
if (syncMultisig) {
284-
await this.initMultisigSyncProgress()
285-
} else {
286-
await this.initSyncProgress()
287-
}
288-
while (this.pollingIndexer) {
289-
await this.synchronize()
290-
await scheduler.wait(5000)
283+
try {
284+
if (syncMultisig) {
285+
await this.initMultisigSyncProgress()
286+
} else {
287+
await this.initSyncProgress()
288+
}
289+
while (this.pollingIndexer) {
290+
await this.synchronize()
291+
await scheduler.wait(5000)
292+
}
293+
} catch (error) {
294+
logger.error(`Error connecting to Light: ${error.message}`)
291295
}
292296
}
293297

@@ -324,15 +328,10 @@ export default class LightSynchronizer extends Synchronizer {
324328
}
325329

326330
public async connect(syncMultisig?: boolean) {
327-
try {
328-
logger.info('LightConnector:\tconnect ...:')
329-
this.pollingIndexer = true
330-
this.syncMultisig = syncMultisig
331-
this.initSync(syncMultisig)
332-
} catch (error) {
333-
logger.error(`Error connecting to Light: ${error.message}`)
334-
throw error
335-
}
331+
logger.info('LightConnector:\tconnect ...:')
332+
this.pollingIndexer = true
333+
this.syncMultisig = syncMultisig
334+
this.initSync(syncMultisig)
336335
}
337336

338337
private async checkTxExist(txHashes: string[]) {

packages/neuron-wallet/src/services/node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ class NodeService {
280280
const network = NetworksService.getInstance().getCurrent()
281281
try {
282282
const res = await rpcRequest<{ error?: { code: number } }>(network.remote, { method: 'get_indexer_tip' })
283-
if (res.error?.code === START_WITHOUT_INDEXER) {
283+
284+
if (res.error?.code === START_WITHOUT_INDEXER || (Array.isArray(res) && res.length === 0)) {
284285
logger.info('Node:\tthe ckb node does not start with --indexer')
285286
return false
286287
}

0 commit comments

Comments
 (0)