Skip to content

Commit

Permalink
Log key on db misses (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 authored Aug 23, 2022
1 parent b706c59 commit fd19af3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion postgres/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package pgipfsethdb

import (
"context"
"database/sql"
"errors"
"fmt"
"math/big"
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fd19af3

Please sign in to comment.