neoneo-go/pkg/consensus/commit.go

36 lines
879 B
Go
Raw Normal View History

2019-11-08 15:40:21 +00:00
package consensus
2019-11-15 10:32:40 +00:00
import (
"github.com/CityOfZion/neo-go/pkg/io"
"github.com/nspcc-dev/dbft/payload"
)
2019-11-08 15:40:21 +00:00
// commit represents dBFT Commit message.
type commit struct {
2019-11-15 10:32:40 +00:00
signature [signatureSize]byte
2019-11-08 15:40:21 +00:00
}
// signatureSize is an rfc6989 signature size in bytes
// without leading byte (0x04, uncompressed)
const signatureSize = 64
2019-11-15 10:32:40 +00:00
var _ payload.Commit = (*commit)(nil)
2019-11-08 15:40:21 +00:00
// EncodeBinary implements io.Serializable interface.
func (c *commit) EncodeBinary(w *io.BinWriter) {
2019-11-15 10:32:40 +00:00
w.WriteBE(c.signature)
2019-11-08 15:40:21 +00:00
}
// DecodeBinary implements io.Serializable interface.
func (c *commit) DecodeBinary(r *io.BinReader) {
2019-11-15 10:32:40 +00:00
r.ReadBE(&c.signature)
}
// Signature implements payload.Commit interface.
func (c commit) Signature() []byte { return c.signature[:] }
// SetSignature implements payload.Commit interface.
func (c *commit) SetSignature(signature []byte) {
copy(c.signature[:], signature)
2019-11-08 15:40:21 +00:00
}