Skip to content

Commit da3c974

Browse files
authored
ethdb/pebble: fix nil callbacks (#26650)
1 parent bf1798e commit da3c974

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ethdb/pebble/pebble.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func (d *Database) onWriteStallEnd() {
117117
// New returns a wrapped pebble DB object. The namespace is the prefix that the
118118
// metrics reporting should use for surfacing internal stats.
119119
func New(file string, cache int, handles int, namespace string, readonly bool) (*Database, error) {
120-
var db *Database
121120
// Ensure we have some minimal caching and file guarantees
122121
if cache < minCache {
123122
cache = minCache
@@ -140,6 +139,11 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
140139
if memTableSize > maxMemTableSize {
141140
memTableSize = maxMemTableSize
142141
}
142+
db := &Database{
143+
fn: file,
144+
log: logger,
145+
quitChan: make(chan chan error),
146+
}
143147
opt := &pebble.Options{
144148
// Pebble has a single combined cache area and the write
145149
// buffers are taken from this too. Assign all available
@@ -187,13 +191,8 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
187191
if err != nil {
188192
return nil, err
189193
}
190-
// Assemble the wrapper with all the registered metrics
191-
db = &Database{
192-
fn: file,
193-
db: innerDB,
194-
log: logger,
195-
quitChan: make(chan chan error),
196-
}
194+
db.db = innerDB
195+
197196
db.compTimeMeter = metrics.NewRegisteredMeter(namespace+"compact/time", nil)
198197
db.compReadMeter = metrics.NewRegisteredMeter(namespace+"compact/input", nil)
199198
db.compWriteMeter = metrics.NewRegisteredMeter(namespace+"compact/output", nil)

0 commit comments

Comments
 (0)