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))
}
rs.storesParams[key] = storeParams{
db: db,
key: key,
typ: typ,
db: db,
}
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) {
db := rs.db
var db dbm.DB
if params.db != nil {
db = params.db
} else {
db = rs.db
db = dbm.NewPrefixDB(rs.db, []byte(params.key.Name()))
}
switch params.typ {
case sdk.StoreTypeMulti:
@ -276,6 +280,7 @@ func (rs *rootMultiStore) nameToKey(name string) StoreKey {
// storeParams
type storeParams struct {
key StoreKey
db dbm.DB
typ StoreType
}