mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
408 B
21 lines
408 B
10 years ago
|
package chain
|
||
10 years ago
|
|
||
|
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()
|
||
|
}
|