Make GetStoreByName private, as only needed by MultiStore Query

This commit is contained in:
Ethan Frey 2018-02-02 15:43:03 +01:00 committed by Ethan Buchman
parent 8765fa32fa
commit c73f08c845
4 changed files with 6 additions and 21 deletions

View File

@ -72,16 +72,3 @@ func (cms cacheMultiStore) GetStore(key StoreKey) Store {
func (cms cacheMultiStore) GetKVStore(key StoreKey) KVStore { func (cms cacheMultiStore) GetKVStore(key StoreKey) KVStore {
return cms.stores[key].(KVStore) return cms.stores[key].(KVStore)
} }
// GetStoreByName will first convert the original name to
// a special key, before looking up the CommitStore.
// This is not exposed to the extensions (which will need the
// StoreKey), but is useful in main, and particularly app.Query,
// in order to convert human strings into CommitStores.
func (cms cacheMultiStore) GetStoreByName(name string) Store {
key := cms.keysByName[name]
if key == nil {
return nil
}
return cms.stores[key].(Store)
}

View File

@ -176,12 +176,12 @@ func (rs *rootMultiStore) GetKVStore(key StoreKey) KVStore {
return rs.stores[key].(KVStore) return rs.stores[key].(KVStore)
} }
// GetStoreByName will first convert the original name to // getStoreByName will first convert the original name to
// a special key, before looking up the CommitStore. // a special key, before looking up the CommitStore.
// This is not exposed to the extensions (which will need the // This is not exposed to the extensions (which will need the
// StoreKey), but is useful in main, and particularly app.Query, // StoreKey), but is useful in main, and particularly app.Query,
// in order to convert human strings into CommitStores. // in order to convert human strings into CommitStores.
func (rs *rootMultiStore) GetStoreByName(name string) Store { func (rs *rootMultiStore) getStoreByName(name string) Store {
key := rs.keysByName[name] key := rs.keysByName[name]
if key == nil { if key == nil {
return nil return nil
@ -199,7 +199,7 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery {
return err.Result().ToQuery() return err.Result().ToQuery()
} }
store := rs.GetStoreByName(storeName) store := rs.getStoreByName(storeName)
if store == nil { if store == nil {
msg := fmt.Sprintf("no such store: %s", storeName) msg := fmt.Sprintf("no such store: %s", storeName)
return sdk.ErrUnknownRequest(msg).Result().ToQuery() return sdk.ErrUnknownRequest(msg).Result().ToQuery()

View File

@ -21,11 +21,11 @@ func TestMultistoreCommitLoad(t *testing.T) {
checkStore(t, store, commitID, commitID) checkStore(t, store, commitID, commitID)
// make sure we can get stores by name // make sure we can get stores by name
s1 := store.GetStoreByName("store1") s1 := store.getStoreByName("store1")
assert.NotNil(t, s1) assert.NotNil(t, s1)
s3 := store.GetStoreByName("store3") s3 := store.getStoreByName("store3")
assert.NotNil(t, s3) assert.NotNil(t, s3)
s77 := store.GetStoreByName("store77") s77 := store.getStoreByName("store77")
assert.Nil(t, s77) assert.Nil(t, s77)
// make a few commits and check them // make a few commits and check them

View File

@ -48,8 +48,6 @@ type MultiStore interface {
// Convenience for fetching substores. // Convenience for fetching substores.
GetStore(StoreKey) Store GetStore(StoreKey) Store
GetKVStore(StoreKey) KVStore GetKVStore(StoreKey) KVStore
GetStoreByName(string) Store
} }
// From MultiStore.CacheMultiStore().... // From MultiStore.CacheMultiStore()....