aboutsummaryrefslogtreecommitdiffstats
path: root/chain/derive_sha.go
blob: 92db90d957b87b707aaaba65f7c05b9c13eccee3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package chain

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()
}