mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 20:21:47 +00:00
types: Hash invoked for nil Data and Header should not panic
Fixes https://github.com/tendermint/tendermint/issues/1298 Fixes https://github.com/tendermint/tendermint/issues/1299 Found while writing tests in https://github.com/tendermint/tendermint/pull/1300
This commit is contained in:
@ -179,7 +179,7 @@ type Header struct {
|
||||
// Hash returns the hash of the header.
|
||||
// Returns nil if ValidatorHash is missing.
|
||||
func (h *Header) Hash() cmn.HexBytes {
|
||||
if len(h.ValidatorsHash) == 0 {
|
||||
if h == nil || len(h.ValidatorsHash) == 0 {
|
||||
return nil
|
||||
}
|
||||
return merkle.SimpleHashFromMap(map[string]merkle.Hasher{
|
||||
@ -413,6 +413,9 @@ type Data struct {
|
||||
|
||||
// Hash returns the hash of the data
|
||||
func (data *Data) Hash() cmn.HexBytes {
|
||||
if data == nil {
|
||||
return (Txs{}).Hash()
|
||||
}
|
||||
if data.hash == nil {
|
||||
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
|
||||
}
|
||||
|
Reference in New Issue
Block a user