From f8bec5fd2baba1b53876e0c7b55083b40511a7d4 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 30 Sep 2019 13:54:30 -0700 Subject: [PATCH] Handle reorgs > 10 blocks --- common/common.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/common.go b/common/common.go index 339f4a7..538e660 100644 --- a/common/common.go +++ b/common/common.go @@ -133,16 +133,17 @@ func BlockIngestor(rpcClient *rpcclient.Client, cache *BlockCache, log *logrus.E } if block != nil { - log.Info("Ingestor adding block to cache: ", height) - cache.Add(height, block) if timeoutCount > 0 { timeoutCount-- } + log.Info("Ingestor adding block to cache: ", height) + err = cache.Add(height, block) + phash = hex.EncodeToString(block.PrevHash) //check for reorgs once we have inital block hash from startup - if hash != phash && reorgCount != -1 { + if err != nil || (hash != phash && reorgCount != -1) { reorgCount++ log.WithFields(logrus.Fields{ "height": height,