// Save writes message to the internal buffer except when heightToStop is
// reached, in which case it will signal the caller via signalWhenStopsTo and
// skip writing.
Save writes message to the internal buffer except when heightToStop is
reached, in which case it will signal the caller via signalWhenStopsTo and
skip writing.
// Save writes message to the internal buffer except when heightToStop is // reached in which case it will signal the caller via signalWhenStopsTo and // skip writing .
func (w *byteBufferWAL) Write(m WALMessage) error {
	if w.stopped {
		w.logger.Debug("WAL already stopped. Not writing message", "msg", m)
		return nil
	}
	if endMsg, ok := m.(EndHeightMessage); ok {
		w.logger.Debug("WAL write end height message", "height", endMsg.Height, "stopHeight", w.heightToStop)
		if endMsg.Height == w.heightToStop {
			w.logger.Debug("Stopping WAL at height", "height", endMsg.Height)
			w.signalWhenStopsTo <- struct{}{}
			w.stopped = true
			return nil
		}
	}
	w.logger.Debug("WAL Write Message", "msg", m)
	err := w.enc.Encode(&TimedWALMessage{fixedTime, m})
	if err != nil {
		panic(fmt.Sprintf("failed to encode the msg %v", m))
	}
	return nil
}
func ( w * byteBufferWAL ) Write ( m WALMessage ) error { if w . stopped { w . logger . Debug ( " " , " " , m ) return nil } if endMsg , ok := m . ( EndHeightMessage ) ; ok { w . logger . Debug ( " " , " " , endMsg . Height , " " , w . heightToStop ) if endMsg . Height == w . heightToStop { w . logger . Debug ( " " , " " , endMsg . Height ) w . signalWhenStopsTo <- struct { } { } w . stopped = true return nil } } w . logger . Debug ( " " , " " , m ) err := w . enc . Encode ( & TimedWALMessage { fixedTime , m } ) if err != nil { panic ( fmt . Sprintf ( " " , m ) ) } return nil }
Save writes message to the internal buffer except when heightToStop is
reached, in which case it will signal the caller via signalWhenStopsTo and
skip writing.
Save writes message to the internal buffer except when heightToStop is reached in which case it will signal the caller via signalWhenStopsTo and skip writing .