neo-go/pkg/consensus/commit.go
Evgenii Stratonikov 10189b6ab3 consensus: extend payloads with StateRoot info
Create and verify witness after block processing.
2020-06-03 13:33:44 +03:00

38 lines
977 B
Go

package consensus
import (
"github.com/nspcc-dev/dbft/payload"
"github.com/nspcc-dev/neo-go/pkg/io"
)
// commit represents dBFT Commit message.
type commit struct {
signature [signatureSize]byte
stateSig [signatureSize]byte
}
// signatureSize is an rfc6989 signature size in bytes
// without leading byte (0x04, uncompressed)
const signatureSize = 64
var _ payload.Commit = (*commit)(nil)
// EncodeBinary implements io.Serializable interface.
func (c *commit) EncodeBinary(w *io.BinWriter) {
w.WriteBytes(c.signature[:])
w.WriteBytes(c.stateSig[:])
}
// DecodeBinary implements io.Serializable interface.
func (c *commit) DecodeBinary(r *io.BinReader) {
r.ReadBytes(c.signature[:])
r.ReadBytes(c.stateSig[:])
}
// 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)
}