Skip to content

Commit

Permalink
fix check if reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR552 committed Mar 6, 2023
1 parent d2d195c commit 1fdbf6d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ func (d *dbManager) loadFromPool() {
// TODO: Move this to a config parameter
time.Sleep(wait * time.Second)

numberOfReorgs, err := d.state.CountReorgs(d.ctx, nil)
if err != nil {
log.Error("failed to get number of reorgs: %v", err)
}

if numberOfReorgs != d.numberOfReorgs {
log.Warnf("New L2 reorg detected")
d.l2ReorgCh <- L2ReorgEvent{}
d.txsStore.Wg.Done()
continue
}

poolTransactions, err := d.txPool.GetNonWIPPendingTxs(d.ctx, false, 0)
if err != nil && err != pgpoolstorage.ErrNotFound {
log.Errorf("load tx from pool: %v", err)
Expand Down Expand Up @@ -161,18 +173,6 @@ func (d *dbManager) DeleteTransactionFromPool(ctx context.Context, txHash common
func (d *dbManager) storeProcessedTxAndDeleteFromPool() {
// TODO: Finish the retry mechanism and error handling
for {
numberOfReorgs, err := d.state.CountReorgs(d.ctx, nil)
if err != nil {
log.Error("failed to get number of reorgs: %v", err)
}

if numberOfReorgs != d.numberOfReorgs {
log.Warnf("New L2 reorg detected")
d.l2ReorgCh <- L2ReorgEvent{}
d.txsStore.Wg.Done()
continue
}

txToStore := <-d.txsStore.Ch
log.Debugf("Storing tx %v", txToStore.txResponse.TxHash)
dbTx, err := d.BeginStateTransaction(d.ctx)
Expand Down

0 comments on commit 1fdbf6d

Please sign in to comment.