You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
441 B

  1. package types
  2. import (
  3. "github.com/tendermint/go-merkle"
  4. )
  5. type Tx []byte
  6. type Txs []Tx
  7. func (txs Txs) Hash() []byte {
  8. // Recursive impl.
  9. // Copied from go-merkle to avoid allocations
  10. switch len(txs) {
  11. case 0:
  12. return nil
  13. case 1:
  14. return merkle.SimpleHashFromBinary(txs[0])
  15. default:
  16. left := Txs(txs[:(len(txs)+1)/2]).Hash()
  17. right := Txs(txs[(len(txs)+1)/2:]).Hash()
  18. return merkle.SimpleHashFromTwoHashes(left, right)
  19. }
  20. }