github.com/koko1123/flow-go-1@v0.29.6/consensus/hotstuff/model/proposal.go (about) 1 package model 2 3 import ( 4 "github.com/koko1123/flow-go-1/model/flow" 5 ) 6 7 // Proposal represent a new proposed block within HotStuff (and thus a 8 // a header in the bigger picture), signed by the proposer. 9 type Proposal struct { 10 Block *Block 11 SigData []byte 12 } 13 14 // ProposerVote extracts the proposer vote from the proposal 15 func (p *Proposal) ProposerVote() *Vote { 16 vote := Vote{ 17 View: p.Block.View, 18 BlockID: p.Block.BlockID, 19 SignerID: p.Block.ProposerID, 20 SigData: p.SigData, 21 } 22 return &vote 23 } 24 25 // ProposalFromFlow turns a flow header into a hotstuff block type. 26 func ProposalFromFlow(header *flow.Header, parentView uint64) *Proposal { 27 28 block := BlockFromFlow(header, parentView) 29 30 proposal := Proposal{ 31 Block: block, 32 SigData: header.ProposerSigData, 33 } 34 35 return &proposal 36 } 37 38 // ProposalToFlow turns a block proposal into a flow header. 39 func ProposalToFlow(proposal *Proposal) *flow.Header { 40 41 block := proposal.Block 42 header := &flow.Header{ 43 ParentID: block.QC.BlockID, 44 PayloadHash: block.PayloadHash, 45 Timestamp: block.Timestamp, 46 View: block.View, 47 ParentVoterIndices: block.QC.SignerIndices, 48 ParentVoterSigData: block.QC.SigData, 49 ProposerID: block.ProposerID, 50 ProposerSigData: proposal.SigData, 51 } 52 53 return header 54 }