mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-26 19:21:44 +00:00
rpc: return tx hash, creates contract, contract addr in broadcast (required some helper functions). Closes #30
This commit is contained in:
@ -61,16 +61,21 @@ func HashFromHashes(hashes [][]byte) []byte {
|
||||
func HashFromBinaries(items []interface{}) []byte {
|
||||
hashes := [][]byte{}
|
||||
for _, item := range items {
|
||||
hasher, n, err := sha256.New(), new(int64), new(error)
|
||||
binary.WriteBinary(item, hasher, n, err)
|
||||
if *err != nil {
|
||||
panic(err)
|
||||
}
|
||||
hashes = append(hashes, hasher.Sum(nil))
|
||||
hashes = append(hashes, HashFromBinary(item))
|
||||
}
|
||||
return HashFromHashes(hashes)
|
||||
}
|
||||
|
||||
// General Convenience
|
||||
func HashFromBinary(item interface{}) []byte {
|
||||
hasher, n, err := sha256.New(), new(int64), new(error)
|
||||
binary.WriteBinary(item, hasher, n, err)
|
||||
if *err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
// Convenience for HashFromHashes.
|
||||
func HashFromHashables(items []Hashable) []byte {
|
||||
hashes := [][]byte{}
|
||||
|
Reference in New Issue
Block a user