cmd/utils, node: switch to Pebble as the default db if none exists (#27136) (#2312)

This commit is contained in:
VM 2024-03-21 11:41:21 +08:00 committed by GitHub
parent 9684ba3a83
commit fdbe2e3cb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 10 deletions

@ -151,8 +151,8 @@ func TestCustomBackend(t *testing.T) {
return nil
}
for i, tt := range []backendTest{
{ // When not specified, it should default to leveldb
execArgs: []string{"--db.engine", "leveldb"},
{ // When not specified, it should default to pebble
execArgs: []string{"--db.engine", "pebble"},
execExpect: "0x0000000000001338",
},
{ // Explicit leveldb

@ -506,7 +506,7 @@ type OpenOptions struct {
//
// type == null type != null
// +----------------------------------------
// db is non-existent | leveldb default | specified type
// db is non-existent | pebble default | specified type
// db is existent | from db | specified type (if compatible)
func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) {
// Reject any unsupported database type
@ -527,12 +527,9 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) {
log.Info("Using leveldb as the backing database")
return NewLevelDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
}
// No pre-existing database, no user-requested one either. Default to Pebble
// on supported platforms and LevelDB on anything else.
// log.Info("Defaulting to pebble as the backing database")
// return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
log.Info("Defaulting to leveldb as the backing database")
return NewLevelDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
// No pre-existing database, no user-requested one either. Default to Pebble.
log.Info("Defaulting to pebble as the backing database")
return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly, o.Ephemeral)
}
// Open opens both a disk-based key-value database such as leveldb or pebble, but also

@ -73,7 +73,7 @@ var DefaultConfig = Config{
MaxPeersPerIP: 0, // by default, it will be same as MaxPeers
NAT: nat.Any(),
},
DBEngine: "", // Use whatever exists, will default to Leveldb if non-existent and supported
DBEngine: "", // Use whatever exists, will default to Pebble if non-existent and supported
}
// DefaultDataDir is the default data directory to use for the databases and other