tendermint/types/tx.go

25 lines
412 B
Go
Raw Normal View History

package types
2014-06-05 02:34:45 -07:00
2016-03-12 10:01:08 -08:00
import (
"github.com/tendermint/go-merkle"
)
2015-11-01 11:34:08 -08:00
type Tx []byte
2016-03-12 10:01:08 -08:00
type Txs []Tx
func (txs Txs) Hash() []byte {
// Recursive impl.
// Copied from go-merkle to avoid allocations
switch len(txs) {
case 0:
return nil
case 1:
return txs[0]
default:
left := Txs(txs[:(len(txs)+1)/2]).Hash()
right := Txs(txs[(len(txs)+1)/2:]).Hash()
return merkle.SimpleHashFromTwoHashes(left, right)
}
}