Skip to content

Commit

Permalink
Make GetStoreByName private, as only needed by MultiStore Query
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey authored and ebuchman committed Feb 6, 2018
1 parent 8765fa3 commit c73f08c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
13 changes: 0 additions & 13 deletions store/cachemultistore.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,3 @@ func (cms cacheMultiStore) GetStore(key StoreKey) Store {
func (cms cacheMultiStore) GetKVStore(key StoreKey) 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)
}
6 changes: 3 additions & 3 deletions store/rootmultistore.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ func (rs *rootMultiStore) GetKVStore(key StoreKey) 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.
// 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 (rs *rootMultiStore) GetStoreByName(name string) Store {
func (rs *rootMultiStore) getStoreByName(name string) Store {
key := rs.keysByName[name]
if key == nil {
return nil
Expand All @@ -199,7 +199,7 @@ func (rs *rootMultiStore) Query(req abci.RequestQuery) abci.ResponseQuery {
return err.Result().ToQuery()
}

store := rs.GetStoreByName(storeName)
store := rs.getStoreByName(storeName)
if store == nil {
msg := fmt.Sprintf("no such store: %s", storeName)
return sdk.ErrUnknownRequest(msg).Result().ToQuery()
Expand Down
6 changes: 3 additions & 3 deletions store/rootmultistore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func TestMultistoreCommitLoad(t *testing.T) {
checkStore(t, store, commitID, commitID)

// make sure we can get stores by name
s1 := store.GetStoreByName("store1")
s1 := store.getStoreByName("store1")
assert.NotNil(t, s1)
s3 := store.GetStoreByName("store3")
s3 := store.getStoreByName("store3")
assert.NotNil(t, s3)
s77 := store.GetStoreByName("store77")
s77 := store.getStoreByName("store77")
assert.Nil(t, s77)

// make a few commits and check them
Expand Down
2 changes: 0 additions & 2 deletions types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ type MultiStore interface {
// Convenience for fetching substores.
GetStore(StoreKey) Store
GetKVStore(StoreKey) KVStore

GetStoreByName(string) Store
}

// From MultiStore.CacheMultiStore()....
Expand Down

0 comments on commit c73f08c

Please sign in to comment.