add absent validators to context
This commit is contained in:
parent
d871605241
commit
aeabdcae5d
|
@ -64,9 +64,10 @@ type BaseApp struct {
|
||||||
// See methods setCheckState and setDeliverState.
|
// See methods setCheckState and setDeliverState.
|
||||||
// .valUpdates accumulate in DeliverTx and are reset in BeginBlock.
|
// .valUpdates accumulate in DeliverTx and are reset in BeginBlock.
|
||||||
// QUESTION: should we put valUpdates in the deliverState.ctx?
|
// QUESTION: should we put valUpdates in the deliverState.ctx?
|
||||||
checkState *state // for CheckTx
|
checkState *state // for CheckTx
|
||||||
deliverState *state // for DeliverTx
|
deliverState *state // for DeliverTx
|
||||||
valUpdates []abci.Validator // cached validator changes from DeliverTx
|
valUpdates []abci.Validator // cached validator changes from DeliverTx
|
||||||
|
absentValidators []int32 // absent validators from begin block
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ abci.Application = (*BaseApp)(nil)
|
var _ abci.Application = (*BaseApp)(nil)
|
||||||
|
@ -383,6 +384,8 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
|
||||||
if app.beginBlocker != nil {
|
if app.beginBlocker != nil {
|
||||||
res = app.beginBlocker(app.deliverState.ctx, req)
|
res = app.beginBlocker(app.deliverState.ctx, req)
|
||||||
}
|
}
|
||||||
|
// set the absent validators for addition to context in deliverTx
|
||||||
|
app.absentValidators = req.AbsentValidators
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,6 +495,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
|
||||||
ctx = app.checkState.ctx.WithTxBytes(txBytes)
|
ctx = app.checkState.ctx.WithTxBytes(txBytes)
|
||||||
} else {
|
} else {
|
||||||
ctx = app.deliverState.ctx.WithTxBytes(txBytes)
|
ctx = app.deliverState.ctx.WithTxBytes(txBytes)
|
||||||
|
ctx = ctx.WithAbsentValidators(app.absentValidators)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate a DeliverTx for gas calculation
|
// Simulate a DeliverTx for gas calculation
|
||||||
|
|
|
@ -129,6 +129,7 @@ const (
|
||||||
contextKeyTxBytes
|
contextKeyTxBytes
|
||||||
contextKeyLogger
|
contextKeyLogger
|
||||||
contextKeyGasMeter
|
contextKeyGasMeter
|
||||||
|
contextKeyAbsentValidators
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: Do not expose MultiStore.
|
// NOTE: Do not expose MultiStore.
|
||||||
|
@ -160,6 +161,9 @@ func (c Context) Logger() log.Logger {
|
||||||
func (c Context) GasMeter() GasMeter {
|
func (c Context) GasMeter() GasMeter {
|
||||||
return c.Value(contextKeyGasMeter).(GasMeter)
|
return c.Value(contextKeyGasMeter).(GasMeter)
|
||||||
}
|
}
|
||||||
|
func (c Context) AbsentValidators() []int32 {
|
||||||
|
return c.Value(contextKeyAbsentValidators).([]int32)
|
||||||
|
}
|
||||||
func (c Context) WithMultiStore(ms MultiStore) Context {
|
func (c Context) WithMultiStore(ms MultiStore) Context {
|
||||||
return c.withValue(contextKeyMultiStore, ms)
|
return c.withValue(contextKeyMultiStore, ms)
|
||||||
}
|
}
|
||||||
|
@ -185,6 +189,9 @@ func (c Context) WithLogger(logger log.Logger) Context {
|
||||||
func (c Context) WithGasMeter(meter GasMeter) Context {
|
func (c Context) WithGasMeter(meter GasMeter) Context {
|
||||||
return c.withValue(contextKeyGasMeter, meter)
|
return c.withValue(contextKeyGasMeter, meter)
|
||||||
}
|
}
|
||||||
|
func (c Context) WithAbsentValidators(AbsentValidators []int32) Context {
|
||||||
|
return c.withValue(contextKeyAbsentValidators, AbsentValidators)
|
||||||
|
}
|
||||||
|
|
||||||
// Cache the multistore and return a new cached context. The cached context is
|
// Cache the multistore and return a new cached context. The cached context is
|
||||||
// written to the context when writeCache is called.
|
// written to the context when writeCache is called.
|
||||||
|
|
Loading…
Reference in New Issue