From f0a5d8d83c57e1c958937d77fb7a43619f2399c5 Mon Sep 17 00:00:00 2001 From: kdeme Date: Mon, 28 Oct 2019 12:56:39 +0100 Subject: [PATCH] Add setting of bloomfilter to topics subscribed to --- wrappers/libnimbus.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wrappers/libnimbus.nim b/wrappers/libnimbus.nim index a280543f9..eb1c520fa 100644 --- a/wrappers/libnimbus.nim +++ b/wrappers/libnimbus.nim @@ -9,7 +9,7 @@ import chronos, chronicles, nimcrypto/[utils, hmac, pbkdf2, hash], tables, - eth/[keys, rlp, p2p], eth/p2p/rlpx_protocols/whisper_protocol, + eth/[keys, rlp, p2p, async_utils], eth/p2p/rlpx_protocols/whisper_protocol, eth/p2p/[discovery, enode, peer_pool, bootnodes, whispernodes] from stew/byteutils import hexToSeqByte, hexToByteArray @@ -126,6 +126,9 @@ proc nimbus_start(port: uint16 = 30303) {.exportc.} = node.addCapability Whisper node.protocolState(Whisper).config.powRequirement = 0.000001 + # TODO: should we start the node with an empty bloomfilter? + # var bloom: Bloom + # node.protocolState(Whisper).config.bloom = bloom var bootnodes: seq[ENode] = @[] for nodeId in MainnetBootnodes: @@ -380,6 +383,10 @@ proc nimbus_subscribe_filter(options: ptr CFilterOptions, result = node.subscribeFilter(filter, c_handler) + # Bloom filter has to follow only the subscribed topics + # TODO: better to have an "adding" proc here + traceAsyncErrors node.setBloomFilter(node.filtersToBloom()) + proc nimbus_unsubscribe_filter(id: cstring): bool {.exportc, foreignThreadGc.} = result = node.unsubscribeFilter($id)