Use new memrange and nim rlp

This commit is contained in:
mratsim 2018-04-11 12:42:04 +02:00 committed by zah
parent 41ffbc4049
commit b7d949eec2
2 changed files with 16 additions and 18 deletions

View File

@ -5,7 +5,7 @@ import
# rlpFields UInt256, table
type
TypeHint* {.pure.} = enum UInt256, Bytes, Any
TypeHint* {.pure.} = enum UInt256, Bytes, Any # TODO Bytes is in conflict with nim-rlp Bytes = seq[byte]
EthTime* = Time

View File

@ -69,7 +69,7 @@ proc setStorage*(db: var AccountStateDB, address: string, slot: UInt256, value:
# TODO fix
if value > 0:
let encodedValue = rlp.encode(value)
storage[slotAsKey] = encodedValue.bytes[encodedValue.ibegin..<encodedValue.iend]
storage[slotAsKey] = encodedValue.decode(Bytes)
else:
storage.del(slotAsKey)
#storage[slotAsKey] = value
@ -91,9 +91,7 @@ proc getStorage*(db: var AccountStateDB, address: string, slot: UInt256): (UInt2
var storage = db.db
if storage.hasKey(slotAsKey):
#result = storage[slotAsKey]
var encodedValue = storage[slotAsKey]
var r = rlpFromBytes(encodedValue.initBytesRange)
result = (r.read(Bytes).bigEndianToInt, true)
result = (storage[slotAsKey].bigEndianToInt, true)
else:
result = (0.u256, false)