2019-11-08 15:40:21 +00:00
|
|
|
package consensus
|
|
|
|
|
2019-11-15 10:32:40 +00:00
|
|
|
import (
|
2024-03-21 19:49:39 +00:00
|
|
|
"github.com/nspcc-dev/dbft"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
2019-11-15 10:32:40 +00:00
|
|
|
)
|
2019-11-08 15:40:21 +00:00
|
|
|
|
|
|
|
// changeView represents dBFT ChangeView message.
|
|
|
|
type changeView struct {
|
2019-11-15 10:32:40 +00:00
|
|
|
newViewNumber byte
|
2020-07-11 07:48:25 +00:00
|
|
|
timestamp uint64
|
2024-03-21 19:49:39 +00:00
|
|
|
reason dbft.ChangeViewReason
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
2024-03-21 19:49:39 +00:00
|
|
|
var _ dbft.ChangeView = (*changeView)(nil)
|
2019-11-15 10:32:40 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// EncodeBinary implements the io.Serializable interface.
|
2019-11-08 15:40:21 +00:00
|
|
|
func (c *changeView) EncodeBinary(w *io.BinWriter) {
|
2020-07-11 07:48:25 +00:00
|
|
|
w.WriteU64LE(c.timestamp)
|
|
|
|
w.WriteB(byte(c.reason))
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// DecodeBinary implements the io.Serializable interface.
|
2019-11-08 15:40:21 +00:00
|
|
|
func (c *changeView) DecodeBinary(r *io.BinReader) {
|
2020-07-11 07:48:25 +00:00
|
|
|
c.timestamp = r.ReadU64LE()
|
2024-03-21 19:49:39 +00:00
|
|
|
c.reason = dbft.ChangeViewReason(r.ReadB())
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
2019-11-15 10:32:40 +00:00
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// NewViewNumber implements the payload.ChangeView interface.
|
2019-11-15 10:32:40 +00:00
|
|
|
func (c changeView) NewViewNumber() byte { return c.newViewNumber }
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// Reason implements the payload.ChangeView interface.
|
2024-03-21 19:49:39 +00:00
|
|
|
func (c changeView) Reason() dbft.ChangeViewReason { return c.reason }
|