Fix log warnings (`==` should have been `!=`) (#2907)

This commit is contained in:
Jordan Hrycaj 2024-12-04 14:36:15 +00:00 committed by GitHub
parent 1101895f92
commit 1d70ba5ff0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -355,7 +355,7 @@ proc getUnclesCount*(
let encodedUncles = block: let encodedUncles = block:
let key = genericHashKey(ommersHash) let key = genericHashKey(ommersHash)
db.ctx.getKvt().get(key.toOpenArray).valueOr: db.ctx.getKvt().get(key.toOpenArray).valueOr:
if error.error == KvtNotFound: if error.error != KvtNotFound:
warn info, ommersHash, error=($$error) warn info, ommersHash, error=($$error)
return ok(0) return ok(0)
return ok(rlpFromBytes(encodedUncles).listLen) return ok(rlpFromBytes(encodedUncles).listLen)
@ -372,7 +372,7 @@ proc getUncles*(
let encodedUncles = block: let encodedUncles = block:
let key = genericHashKey(ommersHash) let key = genericHashKey(ommersHash)
db.ctx.getKvt().get(key.toOpenArray).valueOr: db.ctx.getKvt().get(key.toOpenArray).valueOr:
if error.error == KvtNotFound: if error.error != KvtNotFound:
warn info, ommersHash, error=($$error) warn info, ommersHash, error=($$error)
return ok(default(seq[Header])) return ok(default(seq[Header]))
return ok(rlp.decode(encodedUncles, seq[Header])) return ok(rlp.decode(encodedUncles, seq[Header]))
@ -474,7 +474,7 @@ proc getUncleHashes*(
let let
key = genericHashKey(header.ommersHash) key = genericHashKey(header.ommersHash)
encodedUncles = db.ctx.getKvt().get(key.toOpenArray).valueOr: encodedUncles = db.ctx.getKvt().get(key.toOpenArray).valueOr:
if error.error == KvtNotFound: if error.error != KvtNotFound:
warn "getUncleHashes()", ommersHash=header.ommersHash, error=($$error) warn "getUncleHashes()", ommersHash=header.ommersHash, error=($$error)
return ok(default(seq[Hash32])) return ok(default(seq[Hash32]))
return ok(rlp.decode(encodedUncles, seq[Header]).mapIt(it.rlpHash)) return ok(rlp.decode(encodedUncles, seq[Header]).mapIt(it.rlpHash))
@ -487,7 +487,7 @@ proc getTransactionKey*(
let let
txKey = transactionHashToBlockKey(transactionHash) txKey = transactionHashToBlockKey(transactionHash)
tx = db.ctx.getKvt().get(txKey.toOpenArray).valueOr: tx = db.ctx.getKvt().get(txKey.toOpenArray).valueOr:
if error.error == KvtNotFound: if error.error != KvtNotFound:
warn "getTransactionKey()", transactionHash, error=($$error) warn "getTransactionKey()", transactionHash, error=($$error)
return ok(default(TransactionKey)) return ok(default(TransactionKey))
return ok(rlp.decode(tx, TransactionKey)) return ok(rlp.decode(tx, TransactionKey))
@ -495,6 +495,7 @@ proc getTransactionKey*(
proc headerExists*(db: CoreDbRef; blockHash: Hash32): bool = proc headerExists*(db: CoreDbRef; blockHash: Hash32): bool =
## Returns True if the header with the given block hash is in our DB. ## Returns True if the header with the given block hash is in our DB.
db.ctx.getKvt().hasKeyRc(genericHashKey(blockHash).toOpenArray).valueOr: db.ctx.getKvt().hasKeyRc(genericHashKey(blockHash).toOpenArray).valueOr:
if error.error != KvtNotFound:
warn "headerExists()", blockHash, error=($$error) warn "headerExists()", blockHash, error=($$error)
return false return false
# => true/false # => true/false