move handshake to state, use Handshaker, more tests

This commit is contained in:
Ethan Buchman
2016-11-06 01:48:39 +00:00
parent befd8b0cb2
commit 4360c360a4
14 changed files with 439 additions and 204 deletions

View File

@ -21,6 +21,27 @@ type Block struct {
LastCommit *Commit `json:"last_commit"`
}
func MakeBlock(height int, chainID string, txs []Tx, commit *Commit,
prevBlockID BlockID, valHash, appHash []byte) (*Block, *PartSet) {
block := &Block{
Header: &Header{
ChainID: chainID,
Height: height,
Time: time.Now(),
NumTxs: len(txs),
LastBlockID: prevBlockID,
ValidatorsHash: valHash,
AppHash: appHash, // state merkle root of txs from the previous block.
},
LastCommit: commit,
Data: &Data{
Txs: txs,
},
}
block.FillHeader()
return block, block.MakePartSet()
}
// Basic validation that doesn't involve state data.
func (b *Block) ValidateBasic(chainID string, lastBlockHeight int, lastBlockID BlockID,
lastBlockTime time.Time, appHash []byte) error {