|
|
@ -4,6 +4,7 @@ import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/tendermint/go-crypto" |
|
|
|
"github.com/tendermint/go-wire" |
|
|
@ -14,6 +15,9 @@ var ( |
|
|
|
ErrInvalidBlockPartHash = errors.New("Error invalid block part hash") |
|
|
|
) |
|
|
|
|
|
|
|
// TimeFormat is RFC3339Millis, used for generating the sigs
|
|
|
|
const TimeFormat = "2006-01-02T15:04:05.999Z07:00" |
|
|
|
|
|
|
|
// Proposal defines a block proposal for the consensus.
|
|
|
|
// It refers to the block only by its PartSetHeader.
|
|
|
|
// It must be signed by the correct proposer for the given Height/Round
|
|
|
@ -22,6 +26,7 @@ var ( |
|
|
|
type Proposal struct { |
|
|
|
Height int64 `json:"height"` |
|
|
|
Round int `json:"round"` |
|
|
|
Timestamp time.Time `json:"timestamp"` |
|
|
|
BlockPartsHeader PartSetHeader `json:"block_parts_header"` |
|
|
|
POLRound int `json:"pol_round"` // -1 if null.
|
|
|
|
POLBlockID BlockID `json:"pol_block_id"` // zero if null.
|
|
|
@ -34,16 +39,23 @@ func NewProposal(height int64, round int, blockPartsHeader PartSetHeader, polRou |
|
|
|
return &Proposal{ |
|
|
|
Height: height, |
|
|
|
Round: round, |
|
|
|
Timestamp: time.Now().UTC(), |
|
|
|
BlockPartsHeader: blockPartsHeader, |
|
|
|
POLRound: polRound, |
|
|
|
POLBlockID: polBlockID, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TimeString returns the canonical encoding of timestamp
|
|
|
|
func (p *Proposal) TimeString() string { |
|
|
|
return p.Timestamp.Format(TimeFormat) |
|
|
|
} |
|
|
|
|
|
|
|
// String returns a string representation of the Proposal.
|
|
|
|
func (p *Proposal) String() string { |
|
|
|
return fmt.Sprintf("Proposal{%v/%v %v (%v,%v) %v}", p.Height, p.Round, |
|
|
|
p.BlockPartsHeader, p.POLRound, p.POLBlockID, p.Signature) |
|
|
|
return fmt.Sprintf("Proposal{%v/%v %v (%v,%v) %v @ %s}", |
|
|
|
p.Height, p.Round, p.BlockPartsHeader, p.POLRound, |
|
|
|
p.POLBlockID, p.Signature, p.TimeString()) |
|
|
|
} |
|
|
|
|
|
|
|
// WriteSignBytes writes the Proposal bytes for signing
|
|
|
|