Skip to content

Commit

Permalink
Fix sync
Browse files Browse the repository at this point in the history
  • Loading branch information
AllFi committed Jul 10, 2024
1 parent c9b36f6 commit a4c2e71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zp-relayer/pool/BasePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ export abstract class BasePool<N extends Network = Network> {

async syncStateFromIndexer(indexerUrl: string) {
let txs = []
let commitIndex = this.state.getNextIndex() / OUTPLUSONE
let offset = this.state.getNextIndex()
let commitIndex = offset / OUTPLUSONE
do {
txs = await this.fetchTransactionsFromIndexer(indexerUrl, this.state.getNextIndex(), 200)
txs = await this.fetchTransactionsFromIndexer(indexerUrl, offset, 200)
for (const tx of txs) {
const outCommit = hexToNumberString('0x' + tx.commitment)
this.optimisticState.addCommitment(commitIndex, Helpers.strToNum(outCommit))
Expand All @@ -199,6 +200,7 @@ export abstract class BasePool<N extends Network = Network> {
}
commitIndex++
}
offset = this.optimisticState.getNextIndex()
} while (txs.length !== 0)
}

Expand Down

0 comments on commit a4c2e71

Please sign in to comment.