Pass serialized form for source and recipient public key

This commit is contained in:
kdeme 2019-11-06 13:57:59 +01:00 committed by zah
parent e7129d364e
commit 3d7cde60e0

View File

@ -31,8 +31,8 @@ type
CReceivedMessage* = object CReceivedMessage* = object
decoded*: ptr byte decoded*: ptr byte
decodedLen*: csize decodedLen*: csize
source*: ref PublicKey source*: ptr byte
recipientPublicKey*: ref PublicKey recipientPublicKey*: ptr byte
timestamp*: uint32 timestamp*: uint32
ttl*: uint32 ttl*: uint32
topic*: Topic topic*: Topic
@ -441,18 +441,19 @@ proc nimbus_subscribe_filter(options: ptr CFilterOptions,
hash: msg.hash hash: msg.hash
) )
# Should be GCed when handler goes out of scope # Could also allocate here, but this should stay in scope until handler
# finishes so it should be fine.
var var
source: ref PublicKey source: array[RawPublicKeySize, byte]
recipientPublicKey: ref PublicKey recipientPublicKey: array[RawPublicKeySize, byte]
if msg.decoded.src.isSome(): if msg.decoded.src.isSome():
new(source) # Need to pass the serialized form
source[] = msg.decoded.src.get() source = msg.decoded.src.get().getRaw()
cmsg.source = source cmsg.source = addr source[0]
if msg.dst.isSome(): if msg.dst.isSome():
new(recipientPublicKey) # Need to pass the serialized form
recipientPublicKey[] = msg.dst.get() recipientPublicKey = msg.decoded.src.get().getRaw()
cmsg.recipientPublicKey = recipientPublicKey cmsg.recipientPublicKey = addr recipientPublicKey[0]
handler(addr cmsg, udata) handler(addr cmsg, udata)