tendermint/consensus/types/proposal.go

48 lines
1.2 KiB
Go
Raw Normal View History

2014-09-14 15:37:32 -07:00
package consensus
import (
"errors"
2014-10-25 14:27:53 -07:00
"fmt"
2014-09-14 15:37:32 -07:00
"io"
2015-04-01 17:30:16 -07:00
"github.com/tendermint/tendermint/account"
"github.com/tendermint/tendermint/binary"
"github.com/tendermint/tendermint/config"
2015-04-01 17:30:16 -07:00
"github.com/tendermint/tendermint/types"
2014-09-14 15:37:32 -07:00
)
var (
ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature")
ErrInvalidBlockPartHash = errors.New("Error invalid block part hash")
)
type Proposal struct {
Height uint
Round uint
BlockParts types.PartSetHeader
POLParts types.PartSetHeader
Signature account.SignatureEd25519
2014-09-14 15:37:32 -07:00
}
func NewProposal(height uint, round uint, blockParts, polParts types.PartSetHeader) *Proposal {
2014-09-14 15:37:32 -07:00
return &Proposal{
2014-10-30 03:32:09 -07:00
Height: height,
Round: round,
BlockParts: blockParts,
POLParts: polParts,
2014-09-14 15:37:32 -07:00
}
}
2014-10-25 14:27:53 -07:00
func (p *Proposal) String() string {
2014-10-30 03:32:09 -07:00
return fmt.Sprintf("Proposal{%v/%v %v %v %v}", p.Height, p.Round,
p.BlockParts, p.POLParts, p.Signature)
2014-10-25 14:27:53 -07:00
}
func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) {
binary.WriteString(config.App().GetString("Network"), w, n, err)
binary.WriteUvarint(p.Height, w, n, err)
binary.WriteUvarint(p.Round, w, n, err)
binary.WriteBinary(p.BlockParts, w, n, err)
binary.WriteBinary(p.POLParts, w, n, err)
}