Skip to content

Commit

Permalink
refactor(store/v2): replace dboptions by dynamic config
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 9, 2024
1 parent 4aeb053 commit a93194c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 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{}
}

0 comments on commit a93194c

Please sign in to comment.