mirror of https://github.com/status-im/nim-rlp.git
Use toInt
This commit is contained in:
parent
1322b81393
commit
99b534f356
3
rlp.nim
3
rlp.nim
|
@ -184,7 +184,7 @@ proc toInt*(self: Rlp, IntType: typedesc): IntType =
|
||||||
raise newException(BadCastError, "")
|
raise newException(BadCastError, "")
|
||||||
|
|
||||||
for i in payloadStart ..< (payloadStart + payloadSize):
|
for i in payloadStart ..< (payloadStart + payloadSize):
|
||||||
result = cast[IntType](result shl 8) or cast[IntType](self.bytes[self.position + i])
|
result = (result shl 8).toInt or (self.bytes[self.position + i]).toInt
|
||||||
|
|
||||||
proc toString*(self: Rlp): string =
|
proc toString*(self: Rlp): string =
|
||||||
if not isBlob():
|
if not isBlob():
|
||||||
|
@ -307,6 +307,7 @@ proc decode*(bytes: openarray[byte]): RlpNode =
|
||||||
rlp = rlpFromBytes initBytesRange(bytesCopy)
|
rlp = rlpFromBytes initBytesRange(bytesCopy)
|
||||||
return rlp.toNodes
|
return rlp.toNodes
|
||||||
|
|
||||||
|
|
||||||
template decode*(bytes: BytesRange, T: typedesc): untyped =
|
template decode*(bytes: BytesRange, T: typedesc): untyped =
|
||||||
var rlp = rlpFromBytes bytes
|
var rlp = rlpFromBytes bytes
|
||||||
rlp.read(T)
|
rlp.read(T)
|
||||||
|
|
Loading…
Reference in New Issue