diff options
author | mr_franklin <mr_franklin@126.com> | 2018-11-23 17:16:14 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-11-23 17:16:14 +0800 |
commit | 2a113f6d72d3b612c6686fa2ab8c30f9e7e6e972 (patch) | |
tree | 9a887825b19319c4f6fe8127fdccf9cd90744837 | |
parent | b24ef5e05d158e1533cf339aea866e0584447cef (diff) | |
download | dexon-2a113f6d72d3b612c6686fa2ab8c30f9e7e6e972.tar.gz dexon-2a113f6d72d3b612c6686fa2ab8c30f9e7e6e972.tar.zst dexon-2a113f6d72d3b612c6686fa2ab8c30f9e7e6e972.zip |
core: return error if repair block failed (#18126)
* core: return error if repair block failed
* make error a bit shorter
-rw-r--r-- | core/blockchain.go | 6 |
1 files changed, 5 insertions, 1 deletions
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 } } |