tendermint/p2p/util.go

16 lines
332 B
Go
Raw Normal View History

2015-10-25 18:21:51 -07:00
package p2p
import (
"crypto/sha256"
)
// doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func doubleSha256(b []byte) []byte {
hasher := sha256.New()
2017-10-03 15:49:20 -07:00
_, _ := hasher.Write(b) // error ignored
2015-10-25 18:21:51 -07:00
sum := hasher.Sum(nil)
hasher.Reset()
2017-10-03 15:49:20 -07:00
_, _ = hasher.Write(sum) // error ignored
2015-10-25 18:21:51 -07:00
return hasher.Sum(nil)
}