|
|
@ -9,7 +9,6 @@ import ( |
|
|
|
"time" |
|
|
|
|
|
|
|
wire "github.com/tendermint/go-wire" |
|
|
|
"github.com/tendermint/go-wire/data" |
|
|
|
cmn "github.com/tendermint/tmlibs/common" |
|
|
|
"github.com/tendermint/tmlibs/merkle" |
|
|
|
"golang.org/x/crypto/ripemd160" |
|
|
@ -86,7 +85,7 @@ func (b *Block) FillHeader() { |
|
|
|
|
|
|
|
// Hash computes and returns the block hash.
|
|
|
|
// If the block is incomplete, block hash is nil for safety.
|
|
|
|
func (b *Block) Hash() data.Bytes { |
|
|
|
func (b *Block) Hash() cmn.HexBytes { |
|
|
|
if b == nil || b.Header == nil || b.Data == nil || b.LastCommit == nil { |
|
|
|
return nil |
|
|
|
} |
|
|
@ -161,22 +160,22 @@ type Header struct { |
|
|
|
TotalTxs int64 `json:"total_txs"` |
|
|
|
|
|
|
|
// hashes of block data
|
|
|
|
LastCommitHash data.Bytes `json:"last_commit_hash"` // commit from validators from the last block
|
|
|
|
DataHash data.Bytes `json:"data_hash"` // transactions
|
|
|
|
LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block
|
|
|
|
DataHash cmn.HexBytes `json:"data_hash"` // transactions
|
|
|
|
|
|
|
|
// hashes from the app output from the prev block
|
|
|
|
ValidatorsHash data.Bytes `json:"validators_hash"` // validators for the current block
|
|
|
|
ConsensusHash data.Bytes `json:"consensus_hash"` // consensus params for current block
|
|
|
|
AppHash data.Bytes `json:"app_hash"` // state after txs from the previous block
|
|
|
|
LastResultsHash data.Bytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block
|
|
|
|
ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block
|
|
|
|
ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block
|
|
|
|
AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block
|
|
|
|
LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block
|
|
|
|
|
|
|
|
// consensus info
|
|
|
|
EvidenceHash data.Bytes `json:"evidence_hash"` // evidence included in the block
|
|
|
|
EvidenceHash cmn.HexBytes `json:"evidence_hash"` // evidence included in the block
|
|
|
|
} |
|
|
|
|
|
|
|
// Hash returns the hash of the header.
|
|
|
|
// Returns nil if ValidatorHash is missing.
|
|
|
|
func (h *Header) Hash() data.Bytes { |
|
|
|
func (h *Header) Hash() cmn.HexBytes { |
|
|
|
if len(h.ValidatorsHash) == 0 { |
|
|
|
return nil |
|
|
|
} |
|
|
@ -246,7 +245,7 @@ type Commit struct { |
|
|
|
|
|
|
|
// Volatile
|
|
|
|
firstPrecommit *Vote |
|
|
|
hash data.Bytes |
|
|
|
hash cmn.HexBytes |
|
|
|
bitArray *cmn.BitArray |
|
|
|
} |
|
|
|
|
|
|
@ -355,7 +354,7 @@ func (commit *Commit) ValidateBasic() error { |
|
|
|
} |
|
|
|
|
|
|
|
// Hash returns the hash of the commit
|
|
|
|
func (commit *Commit) Hash() data.Bytes { |
|
|
|
func (commit *Commit) Hash() cmn.HexBytes { |
|
|
|
if commit.hash == nil { |
|
|
|
bs := make([]merkle.Hasher, len(commit.Precommits)) |
|
|
|
for i, precommit := range commit.Precommits { |
|
|
@ -403,11 +402,11 @@ type Data struct { |
|
|
|
Txs Txs `json:"txs"` |
|
|
|
|
|
|
|
// Volatile
|
|
|
|
hash data.Bytes |
|
|
|
hash cmn.HexBytes |
|
|
|
} |
|
|
|
|
|
|
|
// Hash returns the hash of the data
|
|
|
|
func (data *Data) Hash() data.Bytes { |
|
|
|
func (data *Data) Hash() cmn.HexBytes { |
|
|
|
if data.hash == nil { |
|
|
|
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
|
|
|
|
} |
|
|
@ -441,11 +440,11 @@ type EvidenceData struct { |
|
|
|
Evidence EvidenceList `json:"evidence"` |
|
|
|
|
|
|
|
// Volatile
|
|
|
|
hash data.Bytes |
|
|
|
hash cmn.HexBytes |
|
|
|
} |
|
|
|
|
|
|
|
// Hash returns the hash of the data.
|
|
|
|
func (data *EvidenceData) Hash() data.Bytes { |
|
|
|
func (data *EvidenceData) Hash() cmn.HexBytes { |
|
|
|
if data.hash == nil { |
|
|
|
data.hash = data.Evidence.Hash() |
|
|
|
} |
|
|
@ -477,7 +476,7 @@ func (data *EvidenceData) StringIndented(indent string) string { |
|
|
|
|
|
|
|
// BlockID defines the unique ID of a block as its Hash and its PartSetHeader
|
|
|
|
type BlockID struct { |
|
|
|
Hash data.Bytes `json:"hash"` |
|
|
|
Hash cmn.HexBytes `json:"hash"` |
|
|
|
PartsHeader PartSetHeader `json:"parts"` |
|
|
|
} |
|
|
|
|
|
|
|