2020-04-22 04:21:39 +00:00
|
|
|
import nimcrypto/[keccak, hash], stew/bitops2
|
|
|
|
|
2020-04-21 11:04:18 +00:00
|
|
|
type
|
|
|
|
TrieNodeType* = enum
|
|
|
|
BranchNodeType
|
|
|
|
ExtensionNodeType
|
|
|
|
AccountNodeType
|
|
|
|
HashNodeType
|
|
|
|
|
|
|
|
AccountType* = enum
|
|
|
|
SimpleAccountType
|
|
|
|
ExtendedAccountType
|
2020-04-22 04:21:39 +00:00
|
|
|
|
2020-04-28 14:06:37 +00:00
|
|
|
const
|
|
|
|
StorageLeafNodeType* = AccountNodeType
|
2020-04-29 04:12:15 +00:00
|
|
|
BlockWitnessVersion* = 0x01
|
|
|
|
|
2020-04-22 04:21:39 +00:00
|
|
|
proc setBranchMaskBit*(x: var uint, i: int) {.inline.} =
|
|
|
|
assert(i >= 0 and i < 17)
|
|
|
|
x = x or (1 shl i).uint
|
|
|
|
|
|
|
|
func branchMaskBitIsSet*(x: uint, i: int): bool {.inline.} =
|
|
|
|
assert(i >= 0 and i < 17)
|
|
|
|
result = ((x shr i.uint) and 1'u) == 1'u
|
|
|
|
|
|
|
|
func constructBranchMask*(b1, b2: byte): uint {.inline.} =
|
|
|
|
result = uint(b1) shl 8 or uint(b2)
|
|
|
|
if countOnes(result) < 2:
|
|
|
|
debugEcho "MASK: ", result
|
|
|
|
assert(countOnes(result) > 1)
|