feat(store/v2): support rocks out of the box (#21649)
This commit is contained in:
parent
aa8bf41eb9
commit
72620a5776
2
server/v2/testdata/app.toml
vendored
2
server/v2/testdata/app.toml
vendored
@ -25,7 +25,7 @@ minimum-gas-prices = '0stake'
|
||||
app-db-backend = 'goleveldb'
|
||||
|
||||
[store.options]
|
||||
# SState storage database type. Currently we support: "sqlite" and "pebble"
|
||||
# SState storage database type. Currently we support: "sqlite", "pebble" and "rocksdb"
|
||||
ss-type = 'sqlite'
|
||||
# State commitment database type. Currently we support: "iavl" and "iavl-v2"
|
||||
sc-type = 'iavl'
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"cosmossdk.io/store/v2/pruning"
|
||||
"cosmossdk.io/store/v2/storage"
|
||||
"cosmossdk.io/store/v2/storage/pebbledb"
|
||||
"cosmossdk.io/store/v2/storage/rocksdb"
|
||||
"cosmossdk.io/store/v2/storage/sqlite"
|
||||
)
|
||||
|
||||
@ -34,7 +35,7 @@ const (
|
||||
|
||||
// app.toml config options
|
||||
type Options struct {
|
||||
SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"SState storage database type. Currently we support: \"sqlite\" and \"pebble\""`
|
||||
SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"SState storage database type. Currently we support: \"sqlite\", \"pebble\" and \"rocksdb\""`
|
||||
SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support: \"iavl\" and \"iavl-v2\""`
|
||||
SSPruningOption *store.PruningOption `mapstructure:"ss-pruning-option" toml:"ss-pruning-option" comment:"Pruning options for state storage"`
|
||||
SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"`
|
||||
@ -103,8 +104,11 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
|
||||
}
|
||||
ssDb, err = pebbledb.New(dir)
|
||||
case SSTypeRocks:
|
||||
// TODO: rocksdb requires build tags so is not supported here by default
|
||||
return nil, errors.New("rocksdb not supported")
|
||||
dir := fmt.Sprintf("%s/data/ss/rocksdb", opts.RootDir)
|
||||
if err = ensureDir(dir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ssDb, err = rocksdb.New(dir)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
66
store/v2/storage/rocksdb/db_noflag.go
Normal file
66
store/v2/storage/rocksdb/db_noflag.go
Normal file
@ -0,0 +1,66 @@
|
||||
//go:build !rocksdb
|
||||
// +build !rocksdb
|
||||
|
||||
package rocksdb
|
||||
|
||||
import (
|
||||
corestore "cosmossdk.io/core/store"
|
||||
"cosmossdk.io/store/v2"
|
||||
"cosmossdk.io/store/v2/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
_ storage.Database = (*Database)(nil)
|
||||
_ store.UpgradableDatabase = (*Database)(nil)
|
||||
)
|
||||
|
||||
type Database struct{}
|
||||
|
||||
func New(dataDir string) (*Database, error) {
|
||||
return &Database{}, nil
|
||||
}
|
||||
|
||||
func (db *Database) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *Database) NewBatch(version uint64) (store.Batch, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) SetLatestVersion(version uint64) error {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) GetLatestVersion() (uint64, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) Has(storeKey []byte, version uint64, key []byte) (bool, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) Get(storeKey []byte, version uint64, key []byte) ([]byte, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
// Prune prunes all versions up to and including the provided version argument.
|
||||
// Internally, this performs a manual compaction, the data with older timestamp
|
||||
// will be GCed by compaction.
|
||||
func (db *Database) Prune(version uint64) error {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) Iterator(storeKey []byte, version uint64, start, end []byte) (corestore.Iterator, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
func (db *Database) ReverseIterator(storeKey []byte, version uint64, start, end []byte) (corestore.Iterator, error) {
|
||||
panic("rocksdb requires a build flag")
|
||||
}
|
||||
|
||||
// PruneStoreKeys will do nothing for RocksDB, it will be pruned by compaction
|
||||
// when the version is pruned
|
||||
func (db *Database) PruneStoreKeys(_ []string, _ uint64) error {
|
||||
return nil
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user