2019-11-08 15:40:21 +00:00
|
|
|
package consensus
|
|
|
|
|
|
|
|
import (
|
2019-11-15 10:32:40 +00:00
|
|
|
"github.com/nspcc-dev/dbft/payload"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2019-11-08 15:40:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// prepareResponse represents dBFT PrepareResponse message.
|
|
|
|
type prepareResponse struct {
|
2019-11-15 10:32:40 +00:00
|
|
|
preparationHash util.Uint256
|
2020-08-09 20:31:34 +00:00
|
|
|
stateRootSig [signatureSize]byte
|
|
|
|
|
|
|
|
stateRootEnabled bool
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
2019-11-15 10:32:40 +00:00
|
|
|
var _ payload.PrepareResponse = (*prepareResponse)(nil)
|
|
|
|
|
2019-11-08 15:40:21 +00:00
|
|
|
// EncodeBinary implements io.Serializable interface.
|
|
|
|
func (p *prepareResponse) EncodeBinary(w *io.BinWriter) {
|
2019-12-06 15:22:21 +00:00
|
|
|
w.WriteBytes(p.preparationHash[:])
|
2020-08-09 20:31:34 +00:00
|
|
|
if p.stateRootEnabled {
|
|
|
|
w.WriteBytes(p.stateRootSig[:])
|
|
|
|
}
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements io.Serializable interface.
|
|
|
|
func (p *prepareResponse) DecodeBinary(r *io.BinReader) {
|
2019-12-06 15:37:46 +00:00
|
|
|
r.ReadBytes(p.preparationHash[:])
|
2020-08-09 20:31:34 +00:00
|
|
|
if p.stateRootEnabled {
|
|
|
|
r.ReadBytes(p.stateRootSig[:])
|
|
|
|
}
|
2019-11-08 15:40:21 +00:00
|
|
|
}
|
2019-11-15 10:32:40 +00:00
|
|
|
|
|
|
|
// PreparationHash implements payload.PrepareResponse interface.
|
|
|
|
func (p *prepareResponse) PreparationHash() util.Uint256 { return p.preparationHash }
|
|
|
|
|
|
|
|
// SetPreparationHash implements payload.PrepareResponse interface.
|
|
|
|
func (p *prepareResponse) SetPreparationHash(h util.Uint256) { p.preparationHash = h }
|