func (cs ConsensusState) ReplayMessages(file string) error {
	return cs.replay(file, false)
}
Full playback, with tests
package consensus
import (
	"bufio"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"os"
	"reflect"
	"strconv"
	"strings"
	"time"
	"go.uber.org/zap"
	csspb "github.com/annchain/annchain/angine/protos/consensus"
	sm "github.com/annchain/annchain/angine/state"
	agtypes "github.com/annchain/annchain/angine/types"
	auto "github.com/annchain/annchain/module/lib/go-autofile"
	. "github.com/annchain/annchain/module/lib/go-common"
	"github.com/annchain/annchain/module/xlib/def"
)
func (cs *ConsensusState) readReplayMessage(msgBytes []byte, newStepCh chan interface{}) error {
	if len(msgBytes) == 0 || msgBytes[0] == '#' {
		return nil
	}
	var err error
	var msg TimedWALMessage
	err = json.Unmarshal(msgBytes, &msg)
	if err != nil {
		fmt.Println("MsgBytes:", string(msgBytes), ",err:", err)
		return fmt.Errorf("Error reading json data: %v", err)
	}
	switch m := msg.GetMsg().(type) {
	case *agtypes.EventDataRoundState:
		cs.logger.Info("Replay: New Step", zap.Int64("height", m.Height), zap.Int64("round", m.Round), zap.String("step", m.Step))
		ticker := time.After(time.Second * 2)
		if newStepCh != nil {
			select {
			case mi := <-newStepCh:
				m2 := mi.(agtypes.EventDataRoundState)
				if m.Height != m2.Height || m.Round != m2.Round || m.Step != m2.Step {
					return fmt.Errorf("RoundState mismatch. Got %v; Expected %v", m2, m)
				}
			case <-ticker:
				return fmt.Errorf("Failed to read off newStepCh")
			}
		}
	case *msgInfo:
		peerKey := m.PeerKey
		if peerKey == "" {
			peerKey = "local"
		}
		switch msg := m.GetMsg().(type) {
		case *csspb.ProposalMessage:
			pdata := msg.Proposal.GetData()
			cs.slogger.Debugw("Replay: Proposal", "height", pdata.Height, "round", pdata.Round, "header",
				pdata.BlockPartsHeader, "pol", pdata.POLRound, "peer", peerKey)
		case *csspb.BlockPartMessage:
			cs.logger.Debug("Replay: BlockPart", zap.Int64("height", msg.Height), zap.Int64("round", msg.Round), zap.String("peer", peerKey))
		case *csspb.VoteMessage:
			v := msg.Vote.Data
			cs.slogger.Debugw("Replay: Vote", "height", v.Height, "round", v.Round, "type", v.Type,
				"blockID", v.BlockID, "peer", peerKey)
		}
		cs.handleMsg(*m, cs.RoundState)
	case *timeoutInfo:
		cs.slogger.Infow("Replay: Timeout", "height", m.Height, "round", m.Round, "step", m.Step, "dur", m.Duration)
		cs.handleTimeout(*m, cs.RoundState)
	default:
		return fmt.Errorf("Replay: Unknown TimedWALMessage type: %v", reflect.TypeOf(msg.Msg))
	}
	return nil
}
func (cs *ConsensusState) CatchupReplay(height def.INT) error {
	return cs.catchupReplay(height)
}
func (cs *ConsensusState) catchupReplay(csHeight def.INT) error {
	cs.replayMode = true
	defer func() { cs.replayMode = false }()
	gr, found, err := cs.wal.group.Search("#HEIGHT: ", makeHeightSearchFunc(csHeight+1))
	if found {
		return errors.New(Fmt("WAL should not contain height %d.", csHeight+1))
	}
	if gr != nil {
		gr.Close()
	}
	gr, found, err = cs.wal.group.Search("#HEIGHT: ", makeHeightSearchFunc(csHeight))
	if err == io.EOF {
		cs.logger.Warn("Replay: wal.group.Search returned EOF", zap.Int64("height", csHeight))
		return nil
	} else if err != nil {
		return err
	}
	if !found {
		return errors.New(Fmt("WAL does not contain height %d.", csHeight))
	}
	defer gr.Close()
	cs.logger.Info("Catchup by replaying consensus messages", zap.Int64("height", csHeight))
	for {
		line, err := gr.ReadLine()
		if err != nil {
			if err == io.EOF {
				break
			} else {
				return err
			}
		}
		if err := cs.readReplayMessage([]byte(line), nil); err != nil {
			return err
		}
	}
	cs.logger.Info("Replay: Done")
	return nil
}
func (cs ConsensusState) ReplayConsole(file string) error {
	return cs.replay(file, true)
}