tutus-chain/pkg/services/stateroot/vote.go

28 lines
692 B
Go

package stateroot
import (
"git.marketally.com/tutus-one/tutus-chain/pkg/crypto/keys"
"git.marketally.com/tutus-one/tutus-chain/pkg/io"
)
// Vote represents a vote message.
type Vote struct {
ValidatorIndex int32
Height uint32
Signature []byte
}
// EncodeBinary implements the io.Serializable interface.
func (p *Vote) EncodeBinary(w *io.BinWriter) {
w.WriteU32LE(uint32(p.ValidatorIndex))
w.WriteU32LE(p.Height)
w.WriteVarBytes(p.Signature)
}
// DecodeBinary implements the io.Serializable interface.
func (p *Vote) DecodeBinary(r *io.BinReader) {
p.ValidatorIndex = int32(r.ReadU32LE())
p.Height = r.ReadU32LE()
p.Signature = r.ReadVarBytes(keys.SignatureLen)
}