Skip to content

Commit 74ecaff

Browse files
rjl493456442holiman
authored andcommitted
ethdb: add pebble for experiment
ethdb/pebble: disable sync-style db write ethdb/pebble: update configs ethdb/pebble: fixes and tests ethdb/pebble: update configs
1 parent c52def7 commit 74ecaff

File tree

6 files changed

+600
-5
lines changed

6 files changed

+600
-5
lines changed

core/rawdb/database.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/ethereum/go-ethereum/ethdb"
2929
"github.com/ethereum/go-ethereum/ethdb/leveldb"
3030
"github.com/ethereum/go-ethereum/ethdb/memorydb"
31+
"github.com/ethereum/go-ethereum/ethdb/pebble"
3132
"github.com/ethereum/go-ethereum/log"
3233
"github.com/olekukonko/tablewriter"
3334
)
@@ -251,6 +252,16 @@ func NewLevelDBDatabase(file string, cache int, handles int, namespace string, r
251252
return NewDatabase(db), nil
252253
}
253254

255+
// NewPebbleDBDatabase creates a persistent key-value database without a freezer
256+
// moving immutable chain segments into cold storage.
257+
func NewPebbleDBDatabase(file string, cache int, handles int, namespace string, readonly bool) (ethdb.Database, error) {
258+
db, err := pebble.New(file, cache, handles, namespace, readonly)
259+
if err != nil {
260+
return nil, err
261+
}
262+
return NewDatabase(db), nil
263+
}
264+
254265
// NewLevelDBDatabaseWithFreezer creates a persistent key-value database with a
255266
// freezer moving immutable chain segments into cold storage.
256267
func NewLevelDBDatabaseWithFreezer(file string, cache int, handles int, freezer string, namespace string, readonly bool) (ethdb.Database, error) {
@@ -266,6 +277,21 @@ func NewLevelDBDatabaseWithFreezer(file string, cache int, handles int, freezer
266277
return frdb, nil
267278
}
268279

280+
// NewPebbleDBDatabaseWithFreezer creates a persistent key-value database with a
281+
// freezer moving immutable chain segments into cold storage.
282+
func NewPebbleDBDatabaseWithFreezer(file string, cache int, handles int, freezer string, namespace string, readonly bool) (ethdb.Database, error) {
283+
kvdb, err := pebble.New(file, cache, handles, namespace, readonly)
284+
if err != nil {
285+
return nil, err
286+
}
287+
frdb, err := NewDatabaseWithFreezer(kvdb, freezer, namespace, readonly)
288+
if err != nil {
289+
kvdb.Close()
290+
return nil, err
291+
}
292+
return frdb, nil
293+
}
294+
269295
type counter uint64
270296

271297
func (c counter) String() string {

0 commit comments

Comments
 (0)