forked from cerc-io/plugeth
Generic hashing method
This commit is contained in:
parent
48125a25eb
commit
665a44646e
20
ethchain/derive_sha.go
Normal file
20
ethchain/derive_sha.go
Normal file
@ -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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user