nimbus-eth1/nimbus/utils.nim

14 lines
431 B
Nim
Raw Normal View History

2019-02-05 19:15:50 +00:00
import eth/trie/db, eth/[trie, rlp, common]
2018-12-03 10:54:19 +00:00
proc calcRootHash[T](items: openArray[T]): Hash256 =
var tr = initHexaryTrie(newMemoryDB())
for i, t in items:
tr.put(rlp.encode(i).toRange, rlp.encode(t).toRange)
return tr.rootHash
template calcTxRoot*(transactions: openArray[Transaction]): Hash256 =
calcRootHash(transactions)
template calcReceiptRoot*(receipts: openArray[Receipt]): Hash256 =
calcRootHash(receipts)