From 03f717427424819ce4e13a7580cb62576add47c5 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Wed, 17 Jul 2024 15:58:54 -0400 Subject: [PATCH] Added RocksDBOptions struct --- opendb_rocksdb.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/opendb_rocksdb.go b/opendb_rocksdb.go index 5e37e07..e2369f2 100644 --- a/opendb_rocksdb.go +++ b/opendb_rocksdb.go @@ -77,6 +77,21 @@ const ( asyncIOReadOptName = "rocksdb.read-async-io" ) +type RocksDBOptions struct { + appOpts AppOptions + dbName string +} + +func (opts *RocksDBOptions) Get(key string) interface{} { + dbSpecificKey := fmt.Sprintf("rocksdb.%v.%v", opts.dbName, key) + if opts.appOpts.Get(dbSpecificKey) != nil { + return opts.appOpts.Get(dbSpecificKey) + } + + fallbackKey := fmt.Sprintf("rocksdb.%v", key) + return opts.appOpts.Get(fallbackKey) +} + // AppOptions is the same interface as provided by cosmos-sdk, see for details: // https://github.com/cosmos/cosmos-sdk/blob/10465a6aabdfc9119ff187ac3ef229f33c06ab45/server/types/app.go#L29-L31 // We added it here to avoid cosmos-sdk dependency.