2015-03-22 19:00:08 -07:00
|
|
|
package types
|
2014-06-05 02:34:45 -07:00
|
|
|
|
2016-03-12 13:01:08 -05:00
|
|
|
import (
|
2017-04-12 18:18:17 -04:00
|
|
|
abci "github.com/tendermint/abci/types"
|
2016-03-12 13:01:08 -05:00
|
|
|
"github.com/tendermint/go-merkle"
|
|
|
|
)
|
|
|
|
|
2015-11-01 11:34:08 -08:00
|
|
|
type Tx []byte
|
2016-03-12 13:01:08 -05:00
|
|
|
|
2016-06-27 20:43:09 -04:00
|
|
|
// NOTE: this is the hash of the go-wire encoded Tx.
|
|
|
|
// Tx has no types at this level, so just length-prefixed.
|
2016-07-12 14:58:16 -04:00
|
|
|
// Alternatively, it may make sense to add types here and let
|
|
|
|
// []byte be type 0x1 so we can have versioned txs if need be in the future.
|
2016-06-27 20:43:09 -04:00
|
|
|
func (tx Tx) Hash() []byte {
|
|
|
|
return merkle.SimpleHashFromBinary(tx)
|
|
|
|
}
|
|
|
|
|
2016-03-12 13:01:08 -05: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:
|
2016-06-27 20:43:09 -04:00
|
|
|
return txs[0].Hash()
|
2016-03-12 13:01:08 -05:00
|
|
|
default:
|
|
|
|
left := Txs(txs[:(len(txs)+1)/2]).Hash()
|
|
|
|
right := Txs(txs[(len(txs)+1)/2:]).Hash()
|
|
|
|
return merkle.SimpleHashFromTwoHashes(left, right)
|
|
|
|
}
|
|
|
|
}
|
2017-04-12 18:18:17 -04:00
|
|
|
|
|
|
|
// TxResult contains results of executing the transaction.
|
|
|
|
//
|
|
|
|
// One usage is indexing transaction results.
|
|
|
|
type TxResult struct {
|
|
|
|
Height uint64 `json:"height"`
|
|
|
|
Index uint32 `json:"index"`
|
|
|
|
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
|
|
|
|
}
|