From 2a113f6d72d3b612c6686fa2ab8c30f9e7e6e972 Mon Sep 17 00:00:00 2001 From: mr_franklin Date: Fri, 23 Nov 2018 17:16:14 +0800 Subject: core: return error if repair block failed (#18126) * core: return error if repair block failed * make error a bit shorter --- core/blockchain.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/blockchain.go') diff --git a/core/blockchain.go b/core/blockchain.go index 3a9caf01e..bcd53d498 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -445,7 +445,11 @@ func (bc *BlockChain) repair(head **types.Block) error { return nil } // Otherwise rewind one block and recheck state availability there - (*head) = bc.GetBlock((*head).ParentHash(), (*head).NumberU64()-1) + block := bc.GetBlock((*head).ParentHash(), (*head).NumberU64()-1) + if block == nil { + return fmt.Errorf("missing block %d [%x]", (*head).NumberU64()-1, (*head).ParentHash()) + } + (*head) = block } } -- cgit v1.2.3