consensus: cswal doesnt write any consensus msgs in light mode

This commit is contained in:
Ethan Buchman 2016-03-05 21:17:21 -05:00
parent df25a22469
commit 2215ad74ff
1 changed files with 6 additions and 7 deletions

View File

@ -61,21 +61,20 @@ func NewWAL(file string, light bool) (*WAL, error) {
}
// called in newStep and for each pass in receiveRoutine
func (wal *WAL) Save(msg ConsensusLogMessageInterface) {
func (wal *WAL) Save(clm ConsensusLogMessageInterface) {
if wal != nil {
if wal.light {
if m, ok := msg.(msgInfo); ok {
if _, ok := m.Msg.(*BlockPartMessage); ok {
return
}
// in light mode we only write new steps and timeouts (no votes, proposals, block parts)
if _, ok := clm.(msgInfo); ok {
return
}
}
var n int
var err error
wire.WriteJSON(ConsensusLogMessage{time.Now(), msg}, wal.fp, &n, &err)
wire.WriteJSON(ConsensusLogMessage{time.Now(), clm}, wal.fp, &n, &err)
wire.WriteTo([]byte("\n"), wal.fp, &n, &err) // one message per line
if err != nil {
PanicQ(Fmt("Error writing msg to consensus wal. Error: %v \n\nMessage: %v", err, msg))
PanicQ(Fmt("Error writing msg to consensus wal. Error: %v \n\nMessage: %v", err, clm))
}
}
}