------------------------------------------------------------------------ Create a block from the latest state MakeBlock builds a block from the current state with the given txs, commit, and evidence. Note it also takes a proposerAddress because the state does not track rounds, and hence does not kno
( height int64, txs []types.Tx, commit *types.Commit, evidence []types.Evidence, proposerAddress []byte, )
| 232 | // and evidence. Note it also takes a proposerAddress because the state does not |
| 233 | // track rounds, and hence does not know the correct proposer. TODO: fix this! |
| 234 | func (state State) MakeBlock( |
| 235 | height int64, |
| 236 | txs []types.Tx, |
| 237 | commit *types.Commit, |
| 238 | evidence []types.Evidence, |
| 239 | proposerAddress []byte, |
| 240 | ) (*types.Block, *types.PartSet) { |
| 241 | // Build base block with block data. |
| 242 | block := types.MakeBlock(height, txs, commit, evidence) |
| 243 | |
| 244 | // Set time. |
| 245 | var timestamp time.Time |
| 246 | if height == state.InitialHeight { |
| 247 | timestamp = state.LastBlockTime // genesis time |
| 248 | } else { |
| 249 | timestamp = MedianTime(commit, state.LastValidators) |
| 250 | } |
| 251 | |
| 252 | // Fill rest of header with state data. |
| 253 | block.Header.Populate( |
| 254 | state.Version.Consensus, state.ChainID, |
| 255 | timestamp, state.LastBlockID, |
| 256 | state.Validators.Hash(), state.NextValidators.Hash(), |
| 257 | types.HashConsensusParams(state.ConsensusParams), state.AppHash, state.LastResultsHash, |
| 258 | proposerAddress, |
| 259 | ) |
| 260 | |
| 261 | return block, block.MakePartSet(types.BlockPartSizeBytes) |
| 262 | } |
| 263 | |
| 264 | // MedianTime computes a median time for a given Commit (based on Timestamp field of votes messages) and the |
| 265 | // corresponding validator set. The computed time is always between timestamps of |