Log key on db misses (#45)

This commit is contained in:
prathamesh0 2022-08-23 12:14:42 +05:30 committed by GitHub
parent b706c596c5
commit fd19af396d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ package pgipfsethdb
import ( import (
"context" "context"
"database/sql"
"errors" "errors"
"fmt" "fmt"
"math/big" "math/big"
@ -28,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"github.com/mailgun/groupcache/v2" "github.com/mailgun/groupcache/v2"
log "github.com/sirupsen/logrus"
) )
var errNotSupported = errors.New("this operation is not supported") 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 // Get retrieves the given key if it's present in the key-value data store
func (d *Database) dbGet(key string) ([]byte, error) { func (d *Database) dbGet(key string) ([]byte, error) {
var data []byte 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 // Get satisfies the ethdb.KeyValueReader interface