github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/services/stateroot/vote.go (about)

     1  package stateroot
     2  
     3  import (
     4  	"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
     5  	"github.com/nspcc-dev/neo-go/pkg/io"
     6  )
     7  
     8  // Vote represents a vote message.
     9  type Vote struct {
    10  	ValidatorIndex int32
    11  	Height         uint32
    12  	Signature      []byte
    13  }
    14  
    15  // EncodeBinary implements the io.Serializable interface.
    16  func (p *Vote) EncodeBinary(w *io.BinWriter) {
    17  	w.WriteU32LE(uint32(p.ValidatorIndex))
    18  	w.WriteU32LE(p.Height)
    19  	w.WriteVarBytes(p.Signature)
    20  }
    21  
    22  // DecodeBinary implements the io.Serializable interface.
    23  func (p *Vote) DecodeBinary(r *io.BinReader) {
    24  	p.ValidatorIndex = int32(r.ReadU32LE())
    25  	p.Height = r.ReadU32LE()
    26  	p.Signature = r.ReadVarBytes(keys.SignatureLen)
    27  }