Support namespacing within RMS db

This commit is contained in:
Jae Kwon 2018-04-12 15:56:41 -07:00
parent 3f2a8e789a
commit 5883c0e942
1 changed files with 7 additions and 2 deletions

View File

@ -56,8 +56,9 @@ func (rs *rootMultiStore) MountStoreWithDB(key StoreKey, typ StoreType, db dbm.D
panic(fmt.Sprintf("rootMultiStore duplicate store key %v", key)) panic(fmt.Sprintf("rootMultiStore duplicate store key %v", key))
} }
rs.storesParams[key] = storeParams{ rs.storesParams[key] = storeParams{
db: db, key: key,
typ: typ, typ: typ,
db: db,
} }
rs.keysByName[key.Name()] = key rs.keysByName[key.Name()] = key
} }
@ -244,9 +245,12 @@ func parsePath(path string) (storeName string, subpath string, err sdk.Error) {
//---------------------------------------- //----------------------------------------
func (rs *rootMultiStore) loadCommitStoreFromParams(id CommitID, params storeParams) (store CommitStore, err error) { func (rs *rootMultiStore) loadCommitStoreFromParams(id CommitID, params storeParams) (store CommitStore, err error) {
db := rs.db var db dbm.DB
if params.db != nil { if params.db != nil {
db = params.db db = params.db
} else {
db = rs.db
db = dbm.NewPrefixDB(rs.db, []byte(params.key.Name()))
} }
switch params.typ { switch params.typ {
case sdk.StoreTypeMulti: case sdk.StoreTypeMulti:
@ -276,6 +280,7 @@ func (rs *rootMultiStore) nameToKey(name string) StoreKey {
// storeParams // storeParams
type storeParams struct { type storeParams struct {
key StoreKey
db dbm.DB db dbm.DB
typ StoreType typ StoreType
} }