mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-29 03:05:49 +00:00
move handshake to state, use Handshaker, more tests
This commit is contained in:
@@ -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 {
|
||||
|
||||
+3
-2
@@ -11,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
// Volatile state for each Validator
|
||||
// Also persisted with the state, but fields change
|
||||
// every height|round so they don't go in merkle.Tree
|
||||
// TODO: make non-volatile identity
|
||||
// - Remove LastCommitHeight, send bitarray of vals that signed in BeginBlock
|
||||
// - Remove Accum - it can be computed, and now valset becomes identifying
|
||||
type Validator struct {
|
||||
Address []byte `json:"address"`
|
||||
PubKey crypto.PubKey `json:"pub_key"`
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
// NOTE: Not goroutine-safe.
|
||||
// NOTE: All get/set to validators should copy the value for safety.
|
||||
// TODO: consider validator Accum overflow
|
||||
// TODO: replace validators []*Validator with github.com/jaekwon/go-ibbs?
|
||||
// TODO: move valset into an iavl tree where key is 'blockbonded|pubkey'
|
||||
type ValidatorSet struct {
|
||||
Validators []*Validator // NOTE: persisted via reflect, must be exported.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user