Skip to content

Commit

Permalink
refactor(store/v2): replace dboptions by dynamic config (#22185)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Oct 10, 2024
1 parent 04c1590 commit 3a03804
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions store/v2/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package db
import (
"fmt"

coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/store/v2"
)

type DBType string
Expand All @@ -18,7 +18,7 @@ const (
DBFileSuffix string = ".db"
)

func NewDB(dbType DBType, name, dataDir string, opts store.DBOptions) (corestore.KVStoreWithBatch, error) {
func NewDB(dbType DBType, name, dataDir string, opts coreserver.DynamicConfig) (corestore.KVStoreWithBatch, error) {
switch dbType {
case DBTypeGoLevelDB:
return NewGoLevelDB(name, dataDir, opts)
Expand Down
4 changes: 2 additions & 2 deletions store/v2/db/goleveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/util"

coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/store/v2"
storeerrors "cosmossdk.io/store/v2/errors"
)

Expand All @@ -28,7 +28,7 @@ type GoLevelDB struct {
db *leveldb.DB
}

func NewGoLevelDB(name, dir string, opts store.DBOptions) (*GoLevelDB, error) {
func NewGoLevelDB(name, dir string, opts coreserver.DynamicConfig) (*GoLevelDB, error) {
defaultOpts := &opt.Options{
Filter: filter.NewBloomFilter(10), // by default, goleveldb doesn't use a bloom filter.
}
Expand Down
4 changes: 2 additions & 2 deletions store/v2/db/pebbledb.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/cockroachdb/pebble"
"github.com/spf13/cast"

coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/store/v2"
storeerrors "cosmossdk.io/store/v2/errors"
)

Expand All @@ -28,7 +28,7 @@ func NewPebbleDB(name, dataDir string) (*PebbleDB, error) {
return NewPebbleDBWithOpts(name, dataDir, nil)
}

func NewPebbleDBWithOpts(name, dataDir string, opts store.DBOptions) (*PebbleDB, error) {
func NewPebbleDBWithOpts(name, dataDir string, opts coreserver.DynamicConfig) (*PebbleDB, error) {
do := &pebble.Options{
MaxConcurrentCompactions: func() int { return 3 }, // default 1
}
Expand Down
4 changes: 2 additions & 2 deletions store/v2/db/rocksdb_noflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package db

import (
coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/store/v2"
)

var _ corestore.KVStoreWithBatch = (*RocksDB)(nil)
Expand All @@ -19,7 +19,7 @@ func NewRocksDB(name, dataDir string) (*RocksDB, error) {
panic("rocksdb must be built with -tags rocksdb")
}

func NewRocksDBWithOpts(dataDir string, opts store.DBOptions) (*RocksDB, error) {
func NewRocksDBWithOpts(dataDir string, opts coreserver.DynamicConfig) (*RocksDB, error) {
panic("rocksdb must be built with -tags rocksdb")
}

Expand Down
5 changes: 0 additions & 5 deletions store/v2/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,3 @@ func (opts *PruningOption) ShouldPrune(version uint64) (bool, uint64) {

return false, 0
}

// DBOptions defines the interface of a database options.
type DBOptions interface {
Get(string) interface{}
}
7 changes: 1 addition & 6 deletions store/v2/root/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ func (roa *Reader) Has(key []byte) (bool, error) {
}

func (roa *Reader) Get(key []byte) ([]byte, error) {
result, err := roa.rootStore.GetStateStorage().Get(roa.actor, roa.version, key)
if err != nil {
return nil, err
}

return result, nil
return roa.rootStore.GetStateStorage().Get(roa.actor, roa.version, key)
}

func (roa *Reader) Iterator(start, end []byte) (corestore.Iterator, error) {
Expand Down

0 comments on commit 3a03804

Please sign in to comment.