changes as per Bucky's review

This commit is contained in:
Anton Kaliaev
2017-05-13 16:22:51 +02:00
parent c9cd8de9c6
commit f8fdbe3dbc
24 changed files with 83 additions and 227 deletions
+3
View File
@@ -456,6 +456,9 @@ func (m *mockTicker) Chan() <-chan timeoutInfo {
return m.c
}
func (mockTicker) SetLogger(log.Logger) {
}
//------------------------------------
func newCounter() abci.Application {
+1 -1
View File
@@ -207,7 +207,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
case DataChannel:
if conR.fastSync {
conR.Logger.Error("Ignoring message received during fastSync", "msg", msg)
conR.Logger.Info("Ignoring message received during fastSync", "msg", msg)
return
}
switch msg := msg.(type) {
+1 -2
View File
@@ -25,7 +25,7 @@ func startConsensusNet(t *testing.T, css []*ConsensusState, N int, subscribeEven
eventChans := make([]chan interface{}, N)
for i := 0; i < N; i++ {
reactors[i] = NewConsensusReactor(css[i], true) // so we dont start the consensus states
reactors[i].SetLogger(log.TestingLogger())
reactors[i].SetLogger(log.TestingLogger().With("reactor", i))
eventSwitch := events.NewEventSwitch()
eventSwitch.SetLogger(log.TestingLogger().With("module", "events"))
@@ -265,7 +265,6 @@ func waitForAndValidateBlock(t *testing.T, n int, activeVals map[string]struct{}
eventChans[j] <- struct{}{}
wg.Done()
t.Logf("[WARN] Done wait group height=%v validator=%v", newBlock.Height, j)
}, css)
}
+2 -2
View File
@@ -229,7 +229,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
blockHeight := int(res.LastBlockHeight) // XXX: beware overflow
appHash := res.LastBlockAppHash
h.logger.Info("ABCI Handshake", "appHeight", blockHeight, "appHash", appHash)
h.logger.Info("ABCI Handshake", "appHeight", blockHeight, "appHash", fmt.Sprintf("%X", appHash))
// TODO: check version
@@ -239,7 +239,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
return errors.New(cmn.Fmt("Error on replay: %v", err))
}
h.logger.Info("Completed ABCI Handshake - Tendermint and App are synced", "appHeight", blockHeight, "appHash", appHash)
h.logger.Info("Completed ABCI Handshake - Tendermint and App are synced", "appHeight", blockHeight, "appHash", fmt.Sprintf("%X", appHash))
// TODO: (on restart) replay mempool
+4 -1
View File
@@ -323,10 +323,13 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
testPartSize = config.Consensus.BlockPartSize
wal, err := NewWAL(walFile, false)
wal.SetLogger(log.TestingLogger())
if err != nil {
t.Fatal(err)
}
wal.SetLogger(log.TestingLogger())
if _, err := wal.Start(); err != nil {
t.Fatal(err)
}
chain, commits, err := makeBlockchainFromWAL(wal)
if err != nil {
t.Fatalf(err.Error())
+14 -3
View File
@@ -16,6 +16,7 @@ import (
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
//-----------------------------------------------------------------------------
@@ -244,6 +245,12 @@ func NewConsensusState(config *cfg.ConsensusConfig, state *sm.State, proxyAppCon
//----------------------------------------
// Public interface
// SetLogger implements Service.
func (cs *ConsensusState) SetLogger(l log.Logger) {
cs.BaseService.Logger = l
cs.timeoutTicker.SetLogger(l)
}
// SetEventSwitch implements events.Eventable
func (cs *ConsensusState) SetEventSwitch(evsw types.EventSwitch) {
cs.evsw = evsw
@@ -371,6 +378,10 @@ func (cs *ConsensusState) OpenWAL(walFile string) (err error) {
if err != nil {
return err
}
wal.SetLogger(cs.Logger.With("wal", walFile))
if _, err := wal.Start(); err != nil {
return err
}
cs.wal = wal
return nil
}
@@ -576,7 +587,7 @@ func (cs *ConsensusState) receiveRoutine(maxSteps int) {
for {
if maxSteps > 0 {
if cs.nSteps >= maxSteps {
cs.Logger.Error("reached max steps. exiting receive routine")
cs.Logger.Info("reached max steps. exiting receive routine")
cs.nSteps = 0
return
}
@@ -904,7 +915,7 @@ func (cs *ConsensusState) defaultDoPrevote(height int, round int) {
// If ProposalBlock is nil, prevote nil.
if cs.ProposalBlock == nil {
cs.Logger.Error("enterPrevote: ProposalBlock is nil")
cs.Logger.Info("enterPrevote: ProposalBlock is nil")
cs.signAddVote(types.VoteTypePrevote, nil, types.PartSetHeader{})
return
}
@@ -1293,7 +1304,7 @@ func (cs *ConsensusState) addProposalBlockPart(height int, part *types.Part, ver
var err error
cs.ProposalBlock = wire.ReadBinary(&types.Block{}, cs.ProposalBlockParts.GetReader(), types.MaxBlockSize, &n, &err).(*types.Block)
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", fmt.Sprintf("%X", cs.ProposalBlock.Hash()))
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
if cs.Step == RoundStepPropose && cs.isProposalComplete() {
// Move onto the next step
cs.enterPrevote(height, cs.Round)
+3
View File
@@ -4,6 +4,7 @@ import (
"time"
. "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
var (
@@ -18,6 +19,8 @@ type TimeoutTicker interface {
Stop() bool
Chan() <-chan timeoutInfo // on which to receive a timeout
ScheduleTimeout(ti timeoutInfo) // reset the timer
SetLogger(log.Logger)
}
// timeoutTicker wraps time.Timer,
+1 -2
View File
@@ -50,8 +50,7 @@ func NewWAL(walFile string, light bool) (*WAL, error) {
light: light,
}
wal.BaseService = *NewBaseService(nil, "WAL", wal)
_, err = wal.Start()
return wal, err
return wal, nil
}
func (wal *WAL) OnStart() error {