(height int64, round int32)
| 1122 | } |
| 1123 | |
| 1124 | func (cs *State) defaultDecideProposal(height int64, round int32) { |
| 1125 | var block *types.Block |
| 1126 | var blockParts *types.PartSet |
| 1127 | |
| 1128 | // Decide on block |
| 1129 | if cs.ValidBlock != nil { |
| 1130 | // If there is valid block, choose that. |
| 1131 | block, blockParts = cs.ValidBlock, cs.ValidBlockParts |
| 1132 | } else { |
| 1133 | // Create a new proposal block from state/txs from the mempool. |
| 1134 | block, blockParts = cs.createProposalBlock() |
| 1135 | if block == nil { |
| 1136 | return |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | // Flush the WAL. Otherwise, we may not recompute the same proposal to sign, |
| 1141 | // and the privValidator will refuse to sign anything. |
| 1142 | if err := cs.wal.FlushAndSync(); err != nil { |
| 1143 | cs.Logger.Error("failed flushing WAL to disk") |
| 1144 | } |
| 1145 | |
| 1146 | // Make proposal |
| 1147 | propBlockID := types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()} |
| 1148 | proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID) |
| 1149 | p := proposal.ToProto() |
| 1150 | if err := cs.privValidator.SignProposal(cs.state.ChainID, p); err == nil { |
| 1151 | proposal.Signature = p.Signature |
| 1152 | |
| 1153 | // send proposal and block parts on internal msg queue |
| 1154 | cs.sendInternalMessage(msgInfo{&ProposalMessage{proposal}, ""}) |
| 1155 | |
| 1156 | for i := 0; i < int(blockParts.Total()); i++ { |
| 1157 | part := blockParts.GetPart(i) |
| 1158 | cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) |
| 1159 | } |
| 1160 | |
| 1161 | cs.Logger.Debug("signed proposal", "height", height, "round", round, "proposal", proposal) |
| 1162 | } else if !cs.replayMode { |
| 1163 | cs.Logger.Error("propose step; failed signing proposal", "height", height, "round", round, "err", err) |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | // Returns true if the proposal block is complete && |
| 1168 | // (if POLRound was proposed, we have +2/3 prevotes from there). |
nothing calls this directly
no test coverage detected