From b7fd5e53367d978c99912ae333145202dd3bcbcd Mon Sep 17 00:00:00 2001 From: Igor Crevar Date: Mon, 12 Jun 2023 12:22:12 +0200 Subject: [PATCH] func (t *BlockTracker) Init() fix --- blocktracker/blocktracker.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blocktracker/blocktracker.go b/blocktracker/blocktracker.go index 8fe71a41..2f7c3fab 100644 --- a/blocktracker/blocktracker.go +++ b/blocktracker/blocktracker.go @@ -112,8 +112,12 @@ func (t *BlockTracker) Init() (err error) { break } block, err = t.provider.GetBlockByHash(block.ParentHash, false) - // if block does not exist (for example reorg happened) GetBlockByHash will return nil, nil - if err != nil || block == nil { + if err != nil { + return + } else if block == nil { + // if block does not exist (for example reorg happened) GetBlockByHash will return nil, nil + err = fmt.Errorf("block with hash %s not found", block.ParentHash) + return } }