paramstore refactor base
rm debug code fix lint fix hack.go
This commit is contained in:
+18
-2
@@ -48,6 +48,8 @@ func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Lo
|
||||
c = c.WithVoteInfos(nil)
|
||||
c = c.WithGasMeter(NewInfiniteGasMeter())
|
||||
c = c.WithMinimumFees(Coins{})
|
||||
c = c.WithKVGasConfig(KVGasConfig())
|
||||
c = c.WithTransientGasConfig(TransientGasConfig())
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -73,12 +75,12 @@ func (c Context) Value(key interface{}) interface{} {
|
||||
|
||||
// KVStore fetches a KVStore from the MultiStore.
|
||||
func (c Context) KVStore(key StoreKey) KVStore {
|
||||
return c.multiStore().GetKVStore(key).Gas(c.GasMeter(), cachedDefaultGasConfig)
|
||||
return c.multiStore().GetKVStore(key).Gas(c.GasMeter(), c.KVGasConfig())
|
||||
}
|
||||
|
||||
// TransientStore fetches a TransientStore from the MultiStore.
|
||||
func (c Context) TransientStore(key StoreKey) KVStore {
|
||||
return c.multiStore().GetKVStore(key).Gas(c.GasMeter(), cachedTransientGasConfig)
|
||||
return c.multiStore().GetKVStore(key).Gas(c.GasMeter(), c.TransientGasConfig())
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
@@ -141,6 +143,8 @@ const (
|
||||
contextKeyVoteInfos
|
||||
contextKeyGasMeter
|
||||
contextKeyMinimumFees
|
||||
contextKeyKVGasConfig
|
||||
contextKeyTransientGasConfig
|
||||
)
|
||||
|
||||
// NOTE: Do not expose MultiStore.
|
||||
@@ -176,6 +180,12 @@ func (c Context) MinimumFees() Coins { return c.Value(contextKeyMinimumFees).(Co
|
||||
|
||||
func (c Context) WithMultiStore(ms MultiStore) Context { return c.withValue(contextKeyMultiStore, ms) }
|
||||
|
||||
func (c Context) KVGasConfig() GasConfig { return c.Value(contextKeyKVGasConfig).(GasConfig) }
|
||||
|
||||
func (c Context) TransientGasConfig() GasConfig {
|
||||
return c.Value(contextKeyTransientGasConfig).(GasConfig)
|
||||
}
|
||||
|
||||
func (c Context) WithBlockHeader(header abci.Header) Context {
|
||||
var _ proto.Message = &header // for cloning.
|
||||
return c.withValue(contextKeyBlockHeader, header)
|
||||
@@ -212,6 +222,12 @@ func (c Context) WithIsCheckTx(isCheckTx bool) Context {
|
||||
func (c Context) WithMinimumFees(minFees Coins) Context {
|
||||
return c.withValue(contextKeyMinimumFees, minFees)
|
||||
}
|
||||
func (c Context) WithKVGasConfig(config GasConfig) Context {
|
||||
return c.withValue(contextKeyKVGasConfig, config)
|
||||
}
|
||||
func (c Context) WithTransientGasConfig(config GasConfig) Context {
|
||||
return c.withValue(contextKeyTransientGasConfig, config)
|
||||
}
|
||||
|
||||
// Cache the multistore and return a new cached context. The cached context is
|
||||
// written to the context when writeCache is called.
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
cachedDefaultGasConfig = DefaultGasConfig()
|
||||
cachedKVGasConfig = KVGasConfig()
|
||||
cachedTransientGasConfig = TransientGasConfig()
|
||||
)
|
||||
|
||||
@@ -86,8 +86,8 @@ type GasConfig struct {
|
||||
IterNextCostFlat Gas
|
||||
}
|
||||
|
||||
// DefaultGasConfig returns a default gas config for KVStores.
|
||||
func DefaultGasConfig() GasConfig {
|
||||
// KVGasConfig returns a default gas config for KVStores.
|
||||
func KVGasConfig() GasConfig {
|
||||
return GasConfig{
|
||||
HasCost: 10,
|
||||
DeleteCost: 10,
|
||||
@@ -103,5 +103,5 @@ func DefaultGasConfig() GasConfig {
|
||||
// TransientGasConfig returns a default gas config for TransientStores.
|
||||
func TransientGasConfig() GasConfig {
|
||||
// TODO: define gasconfig for transient stores
|
||||
return DefaultGasConfig()
|
||||
return KVGasConfig()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user