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"
|
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
|
|
|
|
|
|
|
// 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
|
2022-04-20 18:30:09 +00:00
|
|
|
// 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)
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// EncodeBinary implements the io.Serializable interface.
|
2019-11-08 15:40:21 +00:00
|
|
|
func (c *commit) EncodeBinary(w *io.BinWriter) {
|
2019-12-06 15:22:21 +00:00
|
|
|
w.WriteBytes(c.signature[:])
|
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 *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
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// Signature implements the payload.Commit interface.
|
2019-11-15 10:32:40 +00:00
|
|
|
func (c commit) Signature() []byte { return c.signature[:] }
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// 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
|
|
|
}
|