Skip to content

Commit

Permalink
Add missing failed block handling during TX processing. Slight rework…
Browse files Browse the repository at this point in the history
… of loop conditionals to support continued workflow in the event of errors
  • Loading branch information
pharr117 committed Nov 14, 2023
1 parent 07afa2c commit 4ffa9f4
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,14 @@ func (idxr *Indexer) processBlocks(wg *sync.WaitGroup, failedBlockHandler core.F
if err != nil {
config.Log.Fatal("Failed to insert failed block event", err)
}
continue
}

config.Log.Infof("Finished parsing block event data for block %d", currentHeight)
} else {
config.Log.Infof("Finished parsing block event data for block %d", currentHeight)

blockEventsDataChan <- &blockEventsDBData{
blockHeight: currentHeight,
blockTime: blockData.BlockData.Block.Time,
blockDBWrapper: blockDBWrapper,
blockEventsDataChan <- &blockEventsDBData{
blockHeight: currentHeight,
blockTime: blockData.BlockData.Block.Time,
blockDBWrapper: blockDBWrapper,
}
}
}

Expand All @@ -340,13 +339,16 @@ func (idxr *Indexer) processBlocks(wg *sync.WaitGroup, failedBlockHandler core.F
if err != nil {
config.Log.Error("ProcessRpcTxs: unhandled error", err)
failedBlockHandler(currentHeight, core.UnprocessableTxError, err)
continue
}

txDataChan <- &dbData{
txDBWrappers: txDBWrappers,
blockTime: blockData.BlockData.Block.Time,
blockHeight: currentHeight,
err := dbTypes.UpsertFailedBlock(idxr.db, currentHeight, idxr.cfg.Probe.ChainID, idxr.cfg.Probe.ChainName)
if err != nil {
config.Log.Fatal("Failed to insert failed block", err)
}
} else {
txDataChan <- &dbData{
txDBWrappers: txDBWrappers,
blockTime: blockData.BlockData.Block.Time,
blockHeight: currentHeight,
}
}

}
Expand Down

0 comments on commit 4ffa9f4

Please sign in to comment.