neo-go/pkg/consensus/commit.go

36 lines
889 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 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) {
w.WriteBytes(c.signature[:])
2019-11-08 15:40:21 +00:00
}
// DecodeBinary implements io.Serializable interface.
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 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
}