update comments

This commit is contained in:
Ethan Buchman
2018-05-20 16:44:08 -04:00
parent 082a02e6d1
commit ee4eb59355
2 changed files with 10 additions and 13 deletions

View File

@ -110,8 +110,9 @@ func (wal *baseWAL) OnStop() {
wal.group.Stop() wal.group.Stop()
} }
// called in newStep and for each receive on the // Write is called in newStep and for each receive on the
// peerMsgQueue and the timoutTicker // peerMsgQueue and the timoutTicker.
// NOTE: does not call fsync()
func (wal *baseWAL) Write(msg WALMessage) { func (wal *baseWAL) Write(msg WALMessage) {
if wal == nil { if wal == nil {
return return
@ -119,25 +120,21 @@ func (wal *baseWAL) Write(msg WALMessage) {
// Write the wal message // Write the wal message
if err := wal.enc.Encode(&TimedWALMessage{time.Now(), msg}); err != nil { if err := wal.enc.Encode(&TimedWALMessage{time.Now(), msg}); err != nil {
cmn.PanicQ(cmn.Fmt("Error writing msg to consensus wal: %v \n\nMessage: %v", err, msg)) panic(cmn.Fmt("Error writing msg to consensus wal: %v \n\nMessage: %v", err, msg))
} }
} }
// called when we receive a msg from ourselves // WriteSync is called when we receive a msg from ourselves
// so that we write to disk before sending signed messages // so that we write to disk before sending signed messages.
// NOTE: calls fsync()
func (wal *baseWAL) WriteSync(msg WALMessage) { func (wal *baseWAL) WriteSync(msg WALMessage) {
if wal == nil { if wal == nil {
return return
} }
// Write the wal message wal.Write(msg)
if err := wal.enc.Encode(&TimedWALMessage{time.Now(), msg}); err != nil {
cmn.PanicQ(cmn.Fmt("Error writing msg to consensus wal: %v \n\nMessage: %v", err, msg))
}
// TODO: only flush when necessary
if err := wal.group.Flush(); err != nil { if err := wal.group.Flush(); err != nil {
cmn.PanicQ(cmn.Fmt("Error flushing consensus wal buf to file. Error: %v \n", err)) panic(cmn.Fmt("Error flushing consensus wal buf to file. Error: %v \n", err))
} }
} }

View File

@ -31,7 +31,7 @@ func TestNodeStartStop(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
select { select {
case <-blockCh: case <-blockCh:
case <-time.After(5 * time.Second): case <-time.After(10 * time.Second):
t.Fatal("timed out waiting for the node to produce a block") t.Fatal("timed out waiting for the node to produce a block")
} }