mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-25 21:07:17 +00:00
21 lines
402 B
Go
21 lines
402 B
Go
package chain
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/ethutil"
|
|
"github.com/ethereum/go-ethereum/trie"
|
|
)
|
|
|
|
type DerivableList interface {
|
|
Len() int
|
|
GetRlp(i int) []byte
|
|
}
|
|
|
|
func DeriveSha(list DerivableList) []byte {
|
|
trie := trie.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()
|
|
}
|