Use toInt

This commit is contained in:
Alexander Ivanov 2018-02-26 14:27:07 +02:00
parent 1322b81393
commit 99b534f356
1 changed files with 2 additions and 1 deletions

View File

@ -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)