Fix wrong log error messages (#1186)

This commit is contained in:
ledgerwatch 2020-10-05 16:56:25 +01:00 committed by GitHub
parent 82193a3670
commit 086952df16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,6 +87,9 @@ func ReadHeaderNumber(db DatabaseReader, hash common.Hash) *uint64 {
if err != nil && !errors.Is(err, ethdb.ErrKeyNotFound) { if err != nil && !errors.Is(err, ethdb.ErrKeyNotFound) {
log.Error("ReadHeaderNumber failed", "err", err) log.Error("ReadHeaderNumber failed", "err", err)
} }
if len(data) == 0 {
return nil
}
if len(data) != 8 { if len(data) != 8 {
log.Error("ReadHeaderNumber got wrong data len", "len", len(data)) log.Error("ReadHeaderNumber got wrong data len", "len", len(data))
return nil 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. // ReadBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
func ReadBodyRLP(db DatabaseReader, hash common.Hash, number uint64) rlp.RawValue { func ReadBodyRLP(db DatabaseReader, hash common.Hash, number uint64) rlp.RawValue {
data, err1 := db.Get(dbutils.BlockBodyPrefix, dbutils.BlockBodyKey(number, hash)) 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) log.Error("ReadBodyRLP failed", "err", err1)
} }
bodyRlp, err := DecompressBlockBody(data) bodyRlp, err := DecompressBlockBody(data)