func (e *MatchEvent) Serialize(w *bytes.Buffer) error {
	return WriteElements(
		w, e.nonce, e.MatchState, e.UnitsFilled, e.MatchedOrder,
		e.RejectReason,
	)
}
Serialize writes the event data to a binary storage format. This does not
serialize the event type as that's handled generically to allow for easy
filtering.

NOTE: This is part of the event.Event interface.
package clientdb
import (
	"bytes"
	"fmt"
	"io"
	"time"
	"github.com/lightninglabs/pool/auctioneerrpc"
	"github.com/lightninglabs/pool/event"
	"github.com/lightninglabs/pool/order"
	"github.com/lightninglabs/pool/poolrpc"
	"go.etcd.io/bbolt"
)
type OrderEvent interface {
	event.Event
	Nonce() order.Nonce
}
type CreatedEvent struct {
	timestamp time.Time
	nonce order.Nonce
}
func NewCreatedEvent(o order.Order) *CreatedEvent {
	return &CreatedEvent{
		timestamp: time.Now(),
		nonce:     o.Nonce(),
	}
}
func (e *CreatedEvent) Type() event.Type {
	return event.TypeOrderCreated
}
func (e *CreatedEvent) Timestamp() time.Time {
	return e.timestamp
}
func (e *CreatedEvent) SetTimestamp(ts time.Time) {
	e.timestamp = ts
}
func (e *CreatedEvent) String() string {
	return "OrderCreated"
}
func (e *CreatedEvent) Serialize(w *bytes.Buffer) error {
	return WriteElements(w, e.nonce)
}
func (e *CreatedEvent) Deserialize(r io.Reader) error {
	return ReadElements(r, &e.nonce)
}
func (e *CreatedEvent) Nonce() order.Nonce {
	return e.nonce
}
var _ event.Event = (*CreatedEvent)(nil)
var _ OrderEvent = (*CreatedEvent)(nil)
type UpdatedEvent struct {
	timestamp time.Time
	nonce order.Nonce
	PrevState order.State
	NewState order.State
	UnitsFilled order.SupplyUnit
}
func NewUpdatedEvent(prevState order.State,
	o order.Order) *UpdatedEvent {
	return &UpdatedEvent{
		timestamp:   time.Now(),
		nonce:       o.Nonce(),
		PrevState:   prevState,
		NewState:    o.Details().State,
		UnitsFilled: o.Details().Units - o.Details().UnitsUnfulfilled,
	}
}
func (e *UpdatedEvent) Type() event.Type {
	return event.TypeOrderStateChange
}
func (e *UpdatedEvent) Timestamp() time.Time {
	return e.timestamp
}
func (e *UpdatedEvent) SetTimestamp(ts time.Time) {
	e.timestamp = ts
}
func (e *UpdatedEvent) String() string {
	return fmt.Sprintf("OrderUpdate(%v)", e.NewState)
}
func (e *UpdatedEvent) Serialize(w *bytes.Buffer) error {
	return WriteElements(w, e.nonce, e.PrevState, e.NewState, e.UnitsFilled)
}
func (e *UpdatedEvent) Deserialize(r io.Reader) error {
	return ReadElements(
		r, &e.nonce, &e.PrevState, &e.NewState, &e.UnitsFilled,
	)
}
func (e *UpdatedEvent) Nonce() order.Nonce {
	return e.nonce
}
var _ event.Event = (*UpdatedEvent)(nil)
var _ OrderEvent = (*UpdatedEvent)(nil)
type MatchEvent struct {
	timestamp time.Time
	nonce order.Nonce
	MatchState order.MatchState
	UnitsFilled order.SupplyUnit
	MatchedOrder order.Nonce
	RejectReason uint32
}
func NewMatchEvent(ts time.Time, nonce order.Nonce, state order.MatchState,
	unitsFilled order.SupplyUnit, matchedOrder order.Nonce,
	rejectReason uint32) *MatchEvent {
	return &MatchEvent{
		timestamp:    ts,
		nonce:        nonce,
		MatchState:   state,
		UnitsFilled:  unitsFilled,
		MatchedOrder: matchedOrder,
		RejectReason: rejectReason,
	}
}
func (e *MatchEvent) Type() event.Type {
	return event.TypeOrderMatch
}
func (e *MatchEvent) Timestamp() time.Time {
	return e.timestamp
}
func (e *MatchEvent) SetTimestamp(ts time.Time) {
	e.timestamp = ts
}
func (e *MatchEvent) String() string {
	return fmt.Sprintf("OrderMatch(%v)", e.MatchState)
}