aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-29 17:29:22 +0800
committerobscuren <geffobscura@gmail.com>2014-10-29 17:29:22 +0800
commit665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a (patch)
tree4f9ff8d5926166a75bd0eb37dcca32d6c9b78c68
parent48125a25eb9f4ece2613559ced5075bde1c75c7a (diff)
downloadgo-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar.gz
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar.bz2
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar.lz
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar.xz
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.tar.zst
go-tangerine-665a44646e9453e37c8a73bdd2c94ba7dc1e7c0a.zip
Generic hashing method
-rw-r--r--ethchain/derive_sha.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/ethchain/derive_sha.go b/ethchain/derive_sha.go
new file mode 100644
index 000000000..b41252e39
--- /dev/null
+++ b/ethchain/derive_sha.go
@@ -0,0 +1,20 @@
+package ethchain
+
+import (
+ "github.com/ethereum/go-ethereum/ethtrie"
+ "github.com/ethereum/go-ethereum/ethutil"
+)
+
+type DerivableList interface {
+ Len() int
+ GetRlp(i int) []byte
+}
+
+func DeriveSha(list DerivableList) []byte {
+ trie := ethtrie.New(ethutil.Config.Db, "")
+ for i := 0; i < list.Len(); i++ {
+ trie.Update(string(ethutil.NewValue(i).Encode()), string(list.GetRlp(i)))
+ }
+
+ return trie.GetRoot()
+}