From 4ffa9f48261ade3c183f8909710a43efb232fc69 Mon Sep 17 00:00:00 2001 From: pharr117 Date: Tue, 14 Nov 2023 18:24:11 -0500 Subject: [PATCH] Add missing failed block handling during TX processing. Slight rework of loop conditionals to support continued workflow in the event of errors --- cmd/index.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/cmd/index.go b/cmd/index.go index 934cf494..1f590521 100644 --- a/cmd/index.go +++ b/cmd/index.go @@ -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, + } } } @@ -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, + } } }