nim-eth/eth/trie/trie_utils.nim

18 lines
433 B
Nim
Raw Normal View History

2019-02-05 12:01:10 +00:00
import
2020-04-18 08:17:59 +00:00
stew/byteutils,
./trie_defs
2019-02-05 12:01:10 +00:00
export trie_defs
2019-02-05 12:01:10 +00:00
template checkValidHashZ*(x: untyped) =
when x.type isnot KeccakHash:
2019-03-13 22:15:26 +00:00
doAssert(x.len == 32 or x.len == 0)
2019-02-05 12:01:10 +00:00
template isZeroHash*(x: openArray[byte]): bool =
2019-02-05 12:01:10 +00:00
x.len == 0
proc hashFromHex*(bits: static[int], input: string): MDigest[bits] =
2020-04-18 08:17:59 +00:00
MDigest(data: hexToByteArray[bits div 8](input))
2019-02-05 12:01:10 +00:00
template hashFromHex*(s: static[string]): untyped = hashFromHex(s.len * 4, s)