Skip to content

Commit

Permalink
viewstore.CacheStore() replaces CacheMultiStoreWithVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
roysc committed Feb 15, 2022
1 parent ccb908d commit 532a6ad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/store/v2/multi"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx"
Expand Down Expand Up @@ -646,11 +645,10 @@ func (app *BaseApp) createQueryContext(height int64, prove bool) (sdk.Context, e
"failed to load state at height %d; %s (latest height: %d)", height, err, app.LastBlockHeight(),
)
}
cacheMS := multi.BasicAsCacheStore(version)

// branch the commit-multistore for safety
ctx := sdk.NewContext(
cacheMS, app.checkState.ctx.BlockHeader(), true, app.logger,
version.CacheWrap(), // branch the commit-multistore for safety
app.checkState.ctx.BlockHeader(), true, app.logger,
).WithMinGasPrices(app.minGasPrices).WithBlockHeight(height)

return ctx, nil
Expand Down
2 changes: 1 addition & 1 deletion baseapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ func (app *BaseApp) NewContextAt(isCheckTx bool, header tmproto.Header, height i
if err != nil {
return sdk.Context{}, err
}
return sdk.NewContext(multi.BasicAsCacheStore(view), header, isCheckTx, app.logger), nil
return sdk.NewContext(view.CacheWrap(), header, isCheckTx, app.logger), nil
}
5 changes: 0 additions & 5 deletions store/v2/multi/cache_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ type noopCacheStore struct {

func (noopCacheStore) Write() {}

// pretend basic store is cache store
func BasicAsCacheStore(bs types.MultiStore) types.CacheMultiStore {
return noopCacheStore{newCacheStore(bs)}
}

// pretend commit store is cache store
func CommitAsCacheStore(s types.CommitMultiStore) types.CacheMultiStore {
return noopCacheStore{newCacheStore(s)}
Expand Down
4 changes: 3 additions & 1 deletion store/v2/multi/view_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ func (vs *viewStore) getSubstore(key string) (*viewSubstore, error) {
}, nil
}

// CacheWrap implements MultiStore.
// Because this store is a read-only view, the returned store's Write operation is a no-op.
func (vs *viewStore) CacheWrap() types.CacheMultiStore {
return newCacheStore(vs)
return noopCacheStore{newCacheStore(vs)}
}

func (s *viewSubstore) GetStateCommitmentStore() *smt.Store {
Expand Down

0 comments on commit 532a6ad

Please sign in to comment.