From 086952df16e3d7753d4cc5c876877f63a1ff7433 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Mon, 5 Oct 2020 16:56:25 +0100 Subject: [PATCH] Fix wrong log error messages (#1186) --- core/rawdb/accessors_chain.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index a77fcbb39..97562d889 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -87,6 +87,9 @@ func ReadHeaderNumber(db DatabaseReader, hash common.Hash) *uint64 { if err != nil && !errors.Is(err, ethdb.ErrKeyNotFound) { log.Error("ReadHeaderNumber failed", "err", err) } + if len(data) == 0 { + return nil + } if len(data) != 8 { log.Error("ReadHeaderNumber got wrong data len", "len", len(data)) return nil @@ -264,7 +267,7 @@ func deleteHeaderWithoutNumber(db DatabaseDeleter, hash common.Hash, number uint // ReadBodyRLP retrieves the block body (transactions and uncles) in RLP encoding. func ReadBodyRLP(db DatabaseReader, hash common.Hash, number uint64) rlp.RawValue { data, err1 := db.Get(dbutils.BlockBodyPrefix, dbutils.BlockBodyKey(number, hash)) - if err1 != nil && errors.Is(err1, ethdb.ErrKeyNotFound) { + if err1 != nil && !errors.Is(err1, ethdb.ErrKeyNotFound) { log.Error("ReadBodyRLP failed", "err", err1) } bodyRlp, err := DecompressBlockBody(data)