From a46cb62272e661b52345a0972d8deeb1748cb705 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sun, 30 Jul 2017 17:34:33 -0400 Subject: [PATCH] Returns all validator changes from DeliverTx in EndBlock --- TODO.md | 3 +-- app/app.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/TODO.md b/TODO.md index 2eb6af8702..e9d2f61eaf 100644 --- a/TODO.md +++ b/TODO.md @@ -4,5 +4,4 @@ * FeeTx and CheckTx changes logic to estimate, not validate * Add tests for new CheckTx -* Handle ValidatorSet responses from DeliverTx calls in EndBlock -* Add InitValidator call to all modules +* Test EndBlock validator set changes diff --git a/app/app.go b/app/app.go index d054592978..f0852b49bd 100644 --- a/app/app.go +++ b/app/app.go @@ -23,11 +23,12 @@ const ( // Basecoin - The ABCI application type Basecoin struct { - info *sm.ChainState - + info *sm.ChainState state *Store handler basecoin.Handler + + pending []*abci.Validator height uint64 logger log.Logger } @@ -109,6 +110,9 @@ func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result { if err != nil { return errors.Result(err) } + if len(res.Diff) > 0 { + app.pending = append(app.pending, res.Diff...) + } return res.ToABCI() } @@ -169,11 +173,11 @@ func (app *Basecoin) BeginBlock(hash []byte, header *abci.Header) { } // EndBlock - ABCI +// Returns a list of all validator changes made in this block func (app *Basecoin) EndBlock(height uint64) (res abci.ResponseEndBlock) { - // for _, plugin := range app.plugins.GetList() { - // pluginRes := plugin.EndBlock(app.state, height) - // res.Diffs = append(res.Diffs, pluginRes.Diffs...) - // } + // TODO: cleanup in case a validator exists multiple times in the list + res.Diffs = app.pending + app.pending = nil return }