neo-go/pkg/consensus/commit.go

36 lines
908 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/nspcc-dev/dbft/payload"
"github.com/nspcc-dev/neo-go/pkg/io"
2019-11-15 10:32:40 +00:00
)
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 a leading byte (0x04, uncompressed).
2019-11-08 15:40:21 +00:00
const signatureSize = 64
2019-11-15 10:32:40 +00:00
var _ payload.Commit = (*commit)(nil)
// EncodeBinary implements the io.Serializable interface.
2019-11-08 15:40:21 +00:00
func (c *commit) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(c.signature[:])
2019-11-08 15:40:21 +00:00
}
// DecodeBinary implements the io.Serializable interface.
2019-11-08 15:40:21 +00:00
func (c *commit) DecodeBinary(r *io.BinReader) {
2019-12-06 15:37:46 +00:00
r.ReadBytes(c.signature[:])
2019-11-15 10:32:40 +00:00
}
// Signature implements the payload.Commit interface.
2019-11-15 10:32:40 +00:00
func (c commit) Signature() []byte { return c.signature[:] }
// SetSignature implements the payload.Commit interface.
2019-11-15 10:32:40 +00:00
func (c *commit) SetSignature(signature []byte) {
copy(c.signature[:], signature)
2019-11-08 15:40:21 +00:00
}