Add setting of bloomfilter to topics subscribed to

This commit is contained in:
kdeme 2019-10-28 12:56:39 +01:00 committed by zah
parent fd71a13142
commit f0a5d8d83c
1 changed files with 8 additions and 1 deletions

View File

@ -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)