broadcast_commit

This commit is contained in:
Ethan Buchman
2016-06-27 20:43:09 -04:00
parent 5fb171edff
commit 65ebc344ac
7 changed files with 102 additions and 3 deletions

View File

@ -6,6 +6,13 @@ import (
type Tx []byte
// NOTE: this is the hash of the go-wire encoded Tx.
// Tx has no types at this level, so just length-prefixed.
// Maybe it should just be the hash of the bytes tho?
func (tx Tx) Hash() []byte {
return merkle.SimpleHashFromBinary(tx)
}
type Txs []Tx
func (txs Txs) Hash() []byte {
@ -15,7 +22,7 @@ func (txs Txs) Hash() []byte {
case 0:
return nil
case 1:
return merkle.SimpleHashFromBinary(txs[0])
return txs[0].Hash()
default:
left := Txs(txs[:(len(txs)+1)/2]).Hash()
right := Txs(txs[(len(txs)+1)/2:]).Hash()