Add InitValidate method for setup

This commit is contained in:
Ethan Frey
2017-08-03 21:41:23 +02:00
parent 4b69f1d5ba
commit 37550ca91d
22 changed files with 164 additions and 39 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ const (
// Chain enforces that this tx was bound to the named chain
type Chain struct {
stack.PassOption
stack.PassInitState
stack.PassInitValidate
}
// Name of the module - fulfills Middleware interface
+10
View File
@@ -3,6 +3,7 @@ package base
import (
"time"
abci "github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
"github.com/tendermint/basecoin"
@@ -70,6 +71,15 @@ func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value s
return res, err
}
// InitValidate logs time and result - fulfills Middlware interface
func (Logger) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next basecoin.InitValidater) {
start := time.Now()
next.InitValidate(l, store, vals)
delta := time.Now().Sub(start)
l = l.With("duration", micros(delta))
l.Info("InitValidate")
}
// micros returns how many microseconds passed in a call
func micros(d time.Duration) int {
return int(d.Seconds() * 1000000)
+1 -1
View File
@@ -18,7 +18,7 @@ package base
// // Multiplexer grabs a MultiTx and sends them sequentially down the line
// type Multiplexer struct {
// stack.PassOption
// stack.PassInitState
// }
// // Name of the module - fulfills Middleware interface