Remove subscribe without handler as we don't provide another mechanism for retrieval of the messages

This commit is contained in:
kdeme 2019-11-18 22:07:08 +01:00 committed by zah
parent 187bd22cc2
commit 83b956c042

View File

@ -326,10 +326,10 @@ proc nimbus_subscribe_filter(options: ptr CFilterOptions,
udata: pointer = nil, id: var Identifier): bool {.exportc.} = udata: pointer = nil, id: var Identifier): bool {.exportc.} =
## Encryption is mandatory. ## Encryption is mandatory.
## A symmetric key or an asymmetric key must be provided. Both is not allowed. ## A symmetric key or an asymmetric key must be provided. Both is not allowed.
## In case of a passed handler, the received msg needs to be copied before the ## The received message needs to be copied before the passed handler ends.
## handler ends.
doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.") doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.")
doAssert(not options.isNil, "Filter options pointer cannot be nil.") doAssert(not options.isNil, "Filter options pointer cannot be nil.")
doAssert(not handler.isNil, "Filter handler cannot be nil." )
var var
src: Option[PublicKey] src: Option[PublicKey]
@ -364,10 +364,6 @@ proc nimbus_subscribe_filter(options: ptr CFilterOptions,
let filter = newFilter(src, privateKey, symKey, @[options.topic], let filter = newFilter(src, privateKey, symKey, @[options.topic],
options.minPow, options.allowP2P) options.minPow, options.allowP2P)
if handler.isNil:
# TODO: call can create `Exception`, why?
hexToBytes(node.subscribeFilter(filter, nil), id)
else:
proc c_handler(msg: ReceivedMessage) {.gcsafe.} = proc c_handler(msg: ReceivedMessage) {.gcsafe.} =
var cmsg = CReceivedMessage( var cmsg = CReceivedMessage(
decoded: unsafeAddr msg.decoded.payload[0], decoded: unsafeAddr msg.decoded.payload[0],