broadcast_commit

This commit is contained in:
Ethan Buchman
2016-07-05 14:26:20 -04:00
parent 5fb171edff
commit 65ebc344ac
7 changed files with 102 additions and 3 deletions
+2
View File
@@ -2,6 +2,7 @@ package types
import (
// for registering TMEventData as events.EventData
. "github.com/tendermint/go-common"
"github.com/tendermint/go-events"
"github.com/tendermint/go-wire"
)
@@ -14,6 +15,7 @@ func EventStringUnbond() string { return "Unbond" }
func EventStringRebond() string { return "Rebond" }
func EventStringDupeout() string { return "Dupeout" }
func EventStringFork() string { return "Fork" }
func EventStringTx(tx Tx) string { return Fmt("Tx:%X", tx.Hash()) }
func EventStringNewBlock() string { return "NewBlock" }
func EventStringNewBlockHeader() string { return "NewBlockHeader" }
+8 -1
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()