Skip to content

Commit

Permalink
fix: Genesis block should be scanned when next scan range
Browse files Browse the repository at this point in the history
starts from block #1
  • Loading branch information
ashchan committed Nov 17, 2019
1 parent 54eda3a commit 6947864
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/neuron-wallet/src/services/sync/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export default class Queue {
this.inProcess = true

if (this.lockHashes.length !== 0) {
const current: bigint = await this.currentBlockNumber.getCurrent()
let current: bigint = await this.currentBlockNumber.getCurrent()
if (current === BigInt(0)) {
// If it scans from genesis block but current block number was already set to 0,
// set it to -1 to make sure `startNumber` would be set to 0.
current = BigInt(-1)
}
const startNumber: bigint = current + BigInt(1)
const endNumber: bigint = current + BigInt(this.fetchSize)
const realEndNumber: bigint = endNumber < this.endBlockNumber ? endNumber : this.endBlockNumber
Expand Down

0 comments on commit 6947864

Please sign in to comment.