mirror of https://github.com/status-im/nim-rlp.git
use Bytes instead of seq[byte]
This commit is contained in:
parent
c4b56ca553
commit
7dd92327de
|
@ -245,24 +245,24 @@ proc initRlpList*(listSize: int): RlpWriter =
|
||||||
startList(result, listSize)
|
startList(result, listSize)
|
||||||
|
|
||||||
# TODO: This should return a lent value
|
# TODO: This should return a lent value
|
||||||
proc finish*(self): seq[byte] =
|
proc finish*(self): Bytes =
|
||||||
if pendingLists.len > 0:
|
if pendingLists.len > 0:
|
||||||
raise newException(PrematureFinalizationError,
|
raise newException(PrematureFinalizationError,
|
||||||
"Insufficient number of elements written to a started list")
|
"Insufficient number of elements written to a started list")
|
||||||
result = output
|
result = output
|
||||||
|
|
||||||
proc encode*[T](v: T): seq[byte] =
|
proc encode*[T](v: T): Bytes =
|
||||||
mixin append
|
mixin append
|
||||||
var writer = initRlpWriter()
|
var writer = initRlpWriter()
|
||||||
writer.append(v)
|
writer.append(v)
|
||||||
return writer.finish
|
return writer.finish
|
||||||
|
|
||||||
proc encodeInt*(i: Integer): seq[byte] =
|
proc encodeInt*(i: Integer): Bytes =
|
||||||
var writer = initRlpWriter()
|
var writer = initRlpWriter()
|
||||||
writer.appendInt(i)
|
writer.appendInt(i)
|
||||||
return writer.finish
|
return writer.finish
|
||||||
|
|
||||||
macro encodeList*(args: varargs[untyped]): seq[byte] =
|
macro encodeList*(args: varargs[untyped]): Bytes =
|
||||||
var
|
var
|
||||||
listLen = args.len
|
listLen = args.len
|
||||||
writer = genSym(nskVar, "rlpWriter")
|
writer = genSym(nskVar, "rlpWriter")
|
||||||
|
|
Loading…
Reference in New Issue