gcs/builder: an empty filter has a zero-hash

This commit is contained in:
Olaoluwa Osuntokun 2017-04-27 21:47:56 -07:00
parent 65172ea539
commit 5a770ec85e

View file

@ -371,6 +371,11 @@ func BuildExtFilter(block *wire.MsgBlock) (*gcs.Filter, error) {
// GetFilterHash returns the double-SHA256 of the filter. // GetFilterHash returns the double-SHA256 of the filter.
func GetFilterHash(filter *gcs.Filter) chainhash.Hash { func GetFilterHash(filter *gcs.Filter) chainhash.Hash {
var zero chainhash.Hash
if filter == nil {
return zero
}
hash1 := chainhash.HashH(filter.NBytes()) hash1 := chainhash.HashH(filter.NBytes())
return chainhash.HashH(hash1[:]) return chainhash.HashH(hash1[:])
} }