Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
fix synchronizer cache data
Browse files Browse the repository at this point in the history
  • Loading branch information
krlosMata committed Jun 8, 2020
1 parent d3173d1 commit 0d610b5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rollup-operator/src/synch.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ class Synchronizer {
this.rollupPoSContract = new this.web3.eth.Contract(rollupPoSABI, this.rollupPoSAddress);
abiDecoder.addABI(rollupPoSABI);
this.forgeEventsCache = new Map();
this.retrySameBatch = 0;
this.cacheBatchToUpdate = 0;
this.mode = mode;

this._initTimeouts(timeouts);
this._initLogger(logLevel);
}
Expand Down Expand Up @@ -272,6 +274,7 @@ class Synchronizer {
const updateFlag = await this._updateEvents([...logsForge,...logsOnChain], lastBatchSaved + 1, targetBlockNumber);
if (!updateFlag) continue;
lastBatchSaved = await this.getLastBatch();
this.cacheBatchToUpdate = lastBatchSaved;
}

totalSynch = (currentBatchDepth == 0) ? 100 : ((lastBatchSaved / currentBatchDepth) * 100);
Expand Down Expand Up @@ -343,6 +346,14 @@ class Synchronizer {
if (lastSynchBlock >= currentBlock - confirmationBlocks)
this.forgeEventsCache.clear();

if (this.cacheBatchToUpdate == batchToSynch)
this.retrySameBatch += 1;

if (this.retrySameBatch > 4){
this.forgeEventsCache.clear();
this.retrySameBatch = 0;
}

let targetBlockNumber = this.forgeEventsCache.get(batchToSynch);
if (!targetBlockNumber){
const logsForge = await this.rollupContract.getPastEvents("ForgeBatch", {
Expand Down

0 comments on commit 0d610b5

Please sign in to comment.