github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/consensus/change_view.go (about)

     1  package consensus
     2  
     3  import (
     4  	"github.com/nspcc-dev/dbft"
     5  	"github.com/nspcc-dev/neo-go/pkg/io"
     6  )
     7  
     8  // changeView represents dBFT ChangeView message.
     9  type changeView struct {
    10  	newViewNumber byte
    11  	timestamp     uint64
    12  	reason        dbft.ChangeViewReason
    13  }
    14  
    15  var _ dbft.ChangeView = (*changeView)(nil)
    16  
    17  // EncodeBinary implements the io.Serializable interface.
    18  func (c *changeView) EncodeBinary(w *io.BinWriter) {
    19  	w.WriteU64LE(c.timestamp)
    20  	w.WriteB(byte(c.reason))
    21  }
    22  
    23  // DecodeBinary implements the io.Serializable interface.
    24  func (c *changeView) DecodeBinary(r *io.BinReader) {
    25  	c.timestamp = r.ReadU64LE()
    26  	c.reason = dbft.ChangeViewReason(r.ReadB())
    27  }
    28  
    29  // NewViewNumber implements the payload.ChangeView interface.
    30  func (c changeView) NewViewNumber() byte { return c.newViewNumber }
    31  
    32  // Reason implements the payload.ChangeView interface.
    33  func (c changeView) Reason() dbft.ChangeViewReason { return c.reason }