neo-go/pkg/consensus/commit.go

31 lines
754 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"
"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
var _ dbft.Commit = (*commit)(nil)
2019-11-15 10:32:40 +00:00
// 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[:] }