Add protoAddress() utility procedure.

This commit is contained in:
cheatfate 2019-10-29 15:38:37 +02:00
parent 6d8f21b611
commit cc0d45c482
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 9 additions and 0 deletions

View File

@ -490,6 +490,15 @@ proc protoArgument*(ma: MultiAddress, value: var openarray[byte]): int =
if len(value) >= result: if len(value) >= result:
copyMem(addr value[0], addr buffer[0], result) copyMem(addr value[0], addr buffer[0], result)
proc protoAddress*(ma: MultiAddress): seq[byte] =
## Returns MultiAddress ``ma`` protocol address binary blob.
##
## If current MultiAddress do not have argument value, then result array will
## be empty.
result = newSeq[byte](len(ma.data.buffer))
let res = protoArgument(ma, result)
result.setLen(res)
proc getPart(ma: MultiAddress, index: int): MultiAddress = proc getPart(ma: MultiAddress, index: int): MultiAddress =
var header: uint64 var header: uint64
var data = newSeq[byte]() var data = newSeq[byte]()