From 08a708e60d2e85afd26338b94752f62cb4e7c26a Mon Sep 17 00:00:00 2001 From: classicalliu Date: Wed, 7 Aug 2019 12:41:01 +0800 Subject: [PATCH] fix: early return when first-not-match --- packages/neuron-wallet/src/services/sync/queue.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/neuron-wallet/src/services/sync/queue.ts b/packages/neuron-wallet/src/services/sync/queue.ts index 3a4f2e94d8..b050a2d741 100644 --- a/packages/neuron-wallet/src/services/sync/queue.ts +++ b/packages/neuron-wallet/src/services/sync/queue.ts @@ -73,7 +73,11 @@ export default class Queue { const blockHeaders: BlockHeader[] = blocks.map(block => block.header) // 2. check blockHeaders - await this.checkBlockHeader(blockHeaders) + const checkResult = await this.checkBlockHeader(blockHeaders) + + if (checkResult.type === 'first-not-match') { + return + } // 3. check and save await this.getBlocksService.checkAndSave(blocks, this.lockHashes) @@ -103,6 +107,8 @@ export default class Queue { throw new Error('chain forked') } } + + return checkResult } public push = (blockNumbers: string[]): void => {