From fd19af396d85641d0ab9decb6e24c66feebd83c9 Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Tue, 23 Aug 2022 12:14:42 +0530 Subject: [PATCH] Log key on db misses (#45) --- postgres/database.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/postgres/database.go b/postgres/database.go index 2163d4d..c21da02 100644 --- a/postgres/database.go +++ b/postgres/database.go @@ -18,6 +18,7 @@ package pgipfsethdb import ( "context" + "database/sql" "errors" "fmt" "math/big" @@ -28,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/jmoiron/sqlx" "github.com/mailgun/groupcache/v2" + log "github.com/sirupsen/logrus" ) var errNotSupported = errors.New("this operation is not supported") @@ -113,7 +115,12 @@ func (d *Database) Has(key []byte) (bool, error) { // Get retrieves the given key if it's present in the key-value data store func (d *Database) dbGet(key string) ([]byte, error) { var data []byte - return data, d.db.Get(&data, getPgStr, key) + err := d.db.Get(&data, getPgStr, key) + if err == sql.ErrNoRows { + log.Warn("Database miss for key", key) + } + + return data, err } // Get satisfies the ethdb.KeyValueReader interface