mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 04:41:22 +00:00
Merge branch 'develop' into jae/literefactor4
This commit is contained in:
@ -17,8 +17,8 @@ import (
|
||||
// TODO: add Version byte
|
||||
type Block struct {
|
||||
mtx sync.Mutex
|
||||
*Header `json:"header"`
|
||||
*Data `json:"data"`
|
||||
Header `json:"header"`
|
||||
Data `json:"data"`
|
||||
Evidence EvidenceData `json:"evidence"`
|
||||
LastCommit *Commit `json:"last_commit"`
|
||||
}
|
||||
@ -27,15 +27,15 @@ type Block struct {
|
||||
// It populates the same set of fields validated by ValidateBasic
|
||||
func MakeBlock(height int64, txs []Tx, commit *Commit) *Block {
|
||||
block := &Block{
|
||||
Header: &Header{
|
||||
Header: Header{
|
||||
Height: height,
|
||||
Time: time.Now(),
|
||||
NumTxs: int64(len(txs)),
|
||||
},
|
||||
LastCommit: commit,
|
||||
Data: &Data{
|
||||
Data: Data{
|
||||
Txs: txs,
|
||||
},
|
||||
LastCommit: commit,
|
||||
}
|
||||
block.fillHeader()
|
||||
return block
|
||||
@ -43,6 +43,9 @@ func MakeBlock(height int64, txs []Tx, commit *Commit) *Block {
|
||||
|
||||
// AddEvidence appends the given evidence to the block
|
||||
func (b *Block) AddEvidence(evidence []Evidence) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
b.Evidence.Evidence = append(b.Evidence.Evidence, evidence...)
|
||||
}
|
||||
|
||||
@ -98,7 +101,7 @@ func (b *Block) Hash() cmn.HexBytes {
|
||||
b.mtx.Lock()
|
||||
defer b.mtx.Unlock()
|
||||
|
||||
if b == nil || b.Header == nil || b.Data == nil || b.LastCommit == nil {
|
||||
if b == nil || b.LastCommit == nil {
|
||||
return nil
|
||||
}
|
||||
b.fillHeader()
|
||||
@ -107,6 +110,7 @@ func (b *Block) Hash() cmn.HexBytes {
|
||||
|
||||
// MakePartSet returns a PartSet containing parts of a serialized block.
|
||||
// This is the form in which the block is gossipped to peers.
|
||||
// CONTRACT: partSize is greater than zero.
|
||||
func (b *Block) MakePartSet(partSize int) *PartSet {
|
||||
if b == nil {
|
||||
return nil
|
||||
@ -209,7 +213,7 @@ type Header struct {
|
||||
// Hash returns the hash of the header.
|
||||
// Returns nil if ValidatorHash is missing,
|
||||
// since a Header is not valid unless there is
|
||||
// a ValidaotrsHash (corresponding to the validator set).
|
||||
// a ValidatorsHash (corresponding to the validator set).
|
||||
func (h *Header) Hash() cmn.HexBytes {
|
||||
if h == nil || len(h.ValidatorsHash) == 0 {
|
||||
return nil
|
||||
@ -397,6 +401,9 @@ func (commit *Commit) ValidateBasic() error {
|
||||
|
||||
// Hash returns the hash of the commit
|
||||
func (commit *Commit) Hash() cmn.HexBytes {
|
||||
if commit == nil {
|
||||
return nil
|
||||
}
|
||||
if commit.hash == nil {
|
||||
bs := make([]merkle.Hasher, len(commit.Precommits))
|
||||
for i, precommit := range commit.Precommits {
|
||||
|
Reference in New Issue
Block a user