aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/derive_sha.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/types/derive_sha.go')
-rw-r--r--core/types/derive_sha.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go
index 593a31f1c..10e3d7446 100644
--- a/core/types/derive_sha.go
+++ b/core/types/derive_sha.go
@@ -1,8 +1,9 @@
package types
import (
- "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
@@ -11,12 +12,13 @@ type DerivableList interface {
GetRlp(i int) []byte
}
-func DeriveSha(list DerivableList) []byte {
+func DeriveSha(list DerivableList) common.Hash {
db, _ := ethdb.NewMemDatabase()
trie := trie.New(nil, db)
for i := 0; i < list.Len(); i++ {
- trie.Update(common.Encode(i), list.GetRlp(i))
+ key, _ := rlp.EncodeToBytes(i)
+ trie.Update(key, list.GetRlp(i))
}
- return trie.Root()
+ return common.BytesToHash(trie.Root())
}