Simplify proposal msg (#2735)

* Align Proposal message with spec

* Update spec
This commit is contained in:
Zarko Milosevic
2018-10-31 15:27:11 +01:00
committed by Ethan Buchman
parent 7a03344480
commit c5905900eb
15 changed files with 82 additions and 85 deletions

View File

@@ -15,43 +15,41 @@ var (
)
// Proposal defines a block proposal for the consensus.
// It refers to the block only by its PartSetHeader.
// It refers to the block by BlockID field.
// It must be signed by the correct proposer for the given Height/Round
// to be considered valid. It may depend on votes from a previous round,
// a so-called Proof-of-Lock (POL) round, as noted in the POLRound and POLBlockID.
// a so-called Proof-of-Lock (POL) round, as noted in the POLRound.
// If POLRound >= 0, then BlockID corresponds to the block that is locked in POLRound.
type Proposal struct {
Type SignedMsgType
Height int64 `json:"height"`
Round int `json:"round"`
POLRound int `json:"pol_round"` // -1 if null.
Timestamp time.Time `json:"timestamp"`
BlockPartsHeader PartSetHeader `json:"block_parts_header"`
POLBlockID BlockID `json:"pol_block_id"` // zero if null.
Signature []byte `json:"signature"`
Type SignedMsgType
Height int64 `json:"height"`
Round int `json:"round"`
POLRound int `json:"pol_round"` // -1 if null.
BlockID BlockID `json:"block_id"`
Timestamp time.Time `json:"timestamp"`
Signature []byte `json:"signature"`
}
// NewProposal returns a new Proposal.
// If there is no POLRound, polRound should be -1.
func NewProposal(height int64, round int, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID) *Proposal {
func NewProposal(height int64, round int, polRound int, blockID BlockID) *Proposal {
return &Proposal{
Type: ProposalType,
Height: height,
Round: round,
POLRound: polRound,
Timestamp: tmtime.Now(),
BlockPartsHeader: blockPartsHeader,
POLBlockID: polBlockID,
Type: ProposalType,
Height: height,
Round: round,
BlockID: blockID,
POLRound: polRound,
Timestamp: tmtime.Now(),
}
}
// String returns a string representation of the Proposal.
func (p *Proposal) String() string {
return fmt.Sprintf("Proposal{%v/%v %v (%v,%v) %X @ %s}",
return fmt.Sprintf("Proposal{%v/%v (%v, %v) %X @ %s}",
p.Height,
p.Round,
p.BlockPartsHeader,
p.BlockID,
p.POLRound,
p.POLBlockID,
cmn.Fingerprint(p.Signature),
CanonicalTime(p.Timestamp))
}