quorum/chain/derive_sha.go

21 lines
402 B
Go
Raw Normal View History

2014-10-31 02:59:17 -07:00
package chain
2014-10-29 02:29:22 -07:00
import (
"github.com/ethereum/go-ethereum/ethutil"
2014-10-31 06:45:03 -07:00
"github.com/ethereum/go-ethereum/trie"
2014-10-29 02:29:22 -07:00
)
type DerivableList interface {
Len() int
GetRlp(i int) []byte
}
func DeriveSha(list DerivableList) []byte {
2014-10-31 06:45:03 -07:00
trie := trie.New(ethutil.Config.Db, "")
2014-10-29 02:29:22 -07:00
for i := 0; i < list.Len(); i++ {
trie.Update(string(ethutil.NewValue(i).Encode()), string(list.GetRlp(i)))
}
return trie.GetRoot()
}