Fix setting of the bloom filter of a filter

This commit is contained in:
kdeme 2019-10-30 13:20:31 +01:00 committed by zah
parent 775ce5ca89
commit ffeac30da7
1 changed files with 10 additions and 8 deletions

View File

@ -342,22 +342,24 @@ proc nimbus_subscribe_filter(options: ptr CFilterOptions,
udata: pointer = nil): cstring {.exportc, foreignThreadGc.} = udata: pointer = nil): cstring {.exportc, foreignThreadGc.} =
## In case of a passed handler, the received msg needs to be copied before the ## In case of a passed handler, the received msg needs to be copied before the
## handler ends. ## handler ends.
## TODO: provide some user context passing here else this is rather useless? var
var filter: Filter src: Option[PublicKey]
symKey: Option[SymKey]
privateKey: Option[PrivateKey]
if not options.source.isNil(): if not options.source.isNil():
filter.src = some(options.source[]) src = some(options.source[])
try: try:
if not options.symKeyID.isNil(): if not options.symKeyID.isNil():
filter.symKey= some(whisperKeys.symKeys[$options.symKeyID]) symKey = some(whisperKeys.symKeys[$options.symKeyID])
if not options.privateKeyID.isNil(): if not options.privateKeyID.isNil():
filter.privateKey= some(whisperKeys.asymKeys[$options.privateKeyID].seckey) privateKey = some(whisperKeys.asymKeys[$options.privateKeyID].seckey)
except KeyError: except KeyError:
return nil return nil
filter.powReq = options.minPow let filter = newFilter(src, privateKey, symKey, @[options.topic],
filter.topics = @[options.topic] options.minPow, options.allowP2P)
filter.allowP2P = options.allowP2P
if handler.isNil: if handler.isNil:
result = node.subscribeFilter(filter, nil) result = node.subscribeFilter(filter, nil)