Skip to content

Commit

Permalink
fix: early return when first-not-match
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 7, 2019
1 parent 5b20d64 commit 08a708e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/neuron-wallet/src/services/sync/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -103,6 +107,8 @@ export default class Queue {
throw new Error('chain forked')
}
}

return checkResult
}

public push = (blockNumbers: string[]): void => {
Expand Down

0 comments on commit 08a708e

Please sign in to comment.