From 007fc330a41c562fbace49ce00ed9ce4c0025cc8 Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Tue, 3 Oct 2017 03:47:26 -0400 Subject: [PATCH] ticker in the begin block logic --- app/app.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/app.go b/app/app.go index eebc816e8..cda2ed8e3 100644 --- a/app/app.go +++ b/app/app.go @@ -163,9 +163,28 @@ func (app *Basecoin) InitChain(req abci.RequestInitChain) { // } } +// Ticker - has the ticker function +type Ticker interface { + Tick(ctx sdk.Context, store sm.SimpleDB) ([]*abci.Validator, error) +} + // BeginBlock - ABCI func (app *Basecoin) BeginBlock(req abci.RequestBeginBlock) { app.height++ + + ticker, ok := app.handler.(Ticker) + if ok { + ctx := stack.NewContext( + app.GetChainID(), + app.height, + app.logger.With("call", "delivertx"), + ) + diff, err := ticker.Tick(ctx, app.state.Append()) + if err != nil { + panic(err) + } + app.addValChange(diff) + } // for _, plugin := range app.plugins.GetList() { // plugin.BeginBlock(app.state, hash, header) // }