cosmos-sdk/baseapp/state/state.go
emmmm bc8ac8108f
fix: multiple typos of different importance (#25068)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
2025-08-04 19:49:30 +00:00

44 lines
866 B
Go

package state
import (
"sync"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type State struct {
MultiStore storetypes.CacheMultiStore
mtx sync.RWMutex
ctx sdk.Context
}
func NewState(ctx sdk.Context, ms storetypes.CacheMultiStore) *State {
return &State{
MultiStore: ms,
ctx: ctx,
}
}
// CacheMultiStore calls and returns a CacheMultiStore on the state's underlying
// CacheMultiStore.
func (st *State) CacheMultiStore() storetypes.CacheMultiStore {
return st.MultiStore.CacheMultiStore()
}
// SetContext updates the state's context to the context provided.
func (st *State) SetContext(ctx sdk.Context) {
st.mtx.Lock()
defer st.mtx.Unlock()
st.ctx = ctx
}
// Context returns the Context of the state.
func (st *State) Context() sdk.Context {
st.mtx.RLock()
defer st.mtx.RUnlock()
return st.ctx
}