mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-28 04:55:33 +00:00
Use new memrange and nim rlp
This commit is contained in:
parent
41ffbc4049
commit
b7d949eec2
@ -5,7 +5,7 @@ import
|
|||||||
# rlpFields UInt256, table
|
# rlpFields UInt256, table
|
||||||
|
|
||||||
type
|
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
|
EthTime* = Time
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ proc setStorage*(db: var AccountStateDB, address: string, slot: UInt256, value:
|
|||||||
# TODO fix
|
# TODO fix
|
||||||
if value > 0:
|
if value > 0:
|
||||||
let encodedValue = rlp.encode(value)
|
let encodedValue = rlp.encode(value)
|
||||||
storage[slotAsKey] = encodedValue.bytes[encodedValue.ibegin..<encodedValue.iend]
|
storage[slotAsKey] = encodedValue.decode(Bytes)
|
||||||
else:
|
else:
|
||||||
storage.del(slotAsKey)
|
storage.del(slotAsKey)
|
||||||
#storage[slotAsKey] = value
|
#storage[slotAsKey] = value
|
||||||
@ -91,9 +91,7 @@ proc getStorage*(db: var AccountStateDB, address: string, slot: UInt256): (UInt2
|
|||||||
var storage = db.db
|
var storage = db.db
|
||||||
if storage.hasKey(slotAsKey):
|
if storage.hasKey(slotAsKey):
|
||||||
#result = storage[slotAsKey]
|
#result = storage[slotAsKey]
|
||||||
var encodedValue = storage[slotAsKey]
|
result = (storage[slotAsKey].bigEndianToInt, true)
|
||||||
var r = rlpFromBytes(encodedValue.initBytesRange)
|
|
||||||
result = (r.read(Bytes).bigEndianToInt, true)
|
|
||||||
else:
|
else:
|
||||||
result = (0.u256, false)
|
result = (0.u256, false)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user