mirror of
https://github.com/tendermint/tendermint.git
synced 2026-06-01 03:46:22 +00:00
cswal: write #HEIGHT:1 for empty wal
This commit is contained in:
@@ -33,7 +33,6 @@ var _ = wire.RegisterInterface(
|
||||
// Can be used for crash-recovery and deterministic replay
|
||||
// TODO: currently the wal is overwritten during replay catchup
|
||||
// give it a mode so it's either reading or appending - must read to end to start appending again
|
||||
// TODO: #HEIGHT 1 is never printed ...
|
||||
type WAL struct {
|
||||
BaseService
|
||||
|
||||
@@ -55,7 +54,19 @@ func NewWAL(walDir string, light bool) (*WAL, error) {
|
||||
light: light,
|
||||
}
|
||||
wal.BaseService = *NewBaseService(log, "WAL", wal)
|
||||
return wal, nil
|
||||
_, err = wal.Start()
|
||||
return wal, err
|
||||
}
|
||||
|
||||
func (wal *WAL) OnStart() error {
|
||||
wal.BaseService.OnStart()
|
||||
size, err := wal.group.Head.Size()
|
||||
if err != nil {
|
||||
return err
|
||||
} else if size == 0 {
|
||||
wal.writeHeight(1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wal *WAL) OnStop() {
|
||||
@@ -81,7 +92,7 @@ func (wal *WAL) Save(wmsg WALMessage) {
|
||||
// Write #HEIGHT: XYZ if new height
|
||||
if edrs, ok := wmsg.(types.EventDataRoundState); ok {
|
||||
if edrs.Step == RoundStepNewHeight.String() {
|
||||
wal.group.WriteLine(Fmt("#HEIGHT: %v", edrs.Height))
|
||||
wal.writeHeight(edrs.Height)
|
||||
}
|
||||
}
|
||||
// Write the wal message
|
||||
@@ -91,3 +102,7 @@ func (wal *WAL) Save(wmsg WALMessage) {
|
||||
PanicQ(Fmt("Error writing msg to consensus wal. Error: %v \n\nMessage: %v", err, wmsg))
|
||||
}
|
||||
}
|
||||
|
||||
func (wal *WAL) writeHeight(height int) {
|
||||
wal.group.WriteLine(Fmt("#HEIGHT: %v", height))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user