diff --git a/eth/p2p/rlpx_protocols/whisper/whisper_types.nim b/eth/p2p/rlpx_protocols/whisper/whisper_types.nim index fce647d..b1d3033 100644 --- a/eth/p2p/rlpx_protocols/whisper/whisper_types.nim +++ b/eth/p2p/rlpx_protocols/whisper/whisper_types.nim @@ -572,7 +572,7 @@ proc add*(self: var Queue, msg: Message): bool = return true # Filters ---------------------------------------------------------------------- -proc newFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](), +proc initFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](), symKey = none[SymKey](), topics: seq[Topic] = @[], powReq = 0.0, allowP2P = false): Filter = # Zero topics will give an empty bloom filter which is fine as this bloom diff --git a/tests/p2p/shh_basic_client.nim b/tests/p2p/shh_basic_client.nim index b20360a..51a710d 100644 --- a/tests/p2p/shh_basic_client.nim +++ b/tests/p2p/shh_basic_client.nim @@ -117,20 +117,20 @@ if config.watch: echo msg.decoded.payload.repr # filter encrypted asym - discard node.subscribeFilter(newFilter(privateKey = some(encPrivateKey), + discard node.subscribeFilter(initFilter(privateKey = some(encPrivateKey), topics = @[topic]), handler) # filter encrypted asym + signed - discard node.subscribeFilter(newFilter(some(signPublicKey), + discard node.subscribeFilter(initFilter(some(signPublicKey), privateKey = some(encPrivateKey), topics = @[topic]), handler) # filter encrypted sym - discard node.subscribeFilter(newFilter(symKey = some(symKey), + discard node.subscribeFilter(initFilter(symKey = some(symKey), topics = @[topic]), handler) # filter encrypted sym + signed - discard node.subscribeFilter(newFilter(some(signPublicKey), + discard node.subscribeFilter(initFilter(some(signPublicKey), symKey = some(symKey), topics = @[topic]), handler) diff --git a/tests/p2p/test_shh.nim b/tests/p2p/test_shh.nim index c3e7ba8..7d270d0 100644 --- a/tests/p2p/test_shh.nim +++ b/tests/p2p/test_shh.nim @@ -269,7 +269,7 @@ suite "Whisper filter": let msg = prepFilterTestMsg(symKey = some(symKey), topic = topic) var filters = initTable[string, Filter]() - let filter = newFilter(symKey = some(symKey), topics = @[topic]) + let filter = initFilter(symKey = some(symKey), topics = @[topic]) let filterId = filters.subscribeFilter(filter) notify(filters, msg) @@ -287,7 +287,7 @@ suite "Whisper filter": topic = topic) var filters = initTable[string, Filter]() - let filter = newFilter(privateKey = some(privKey), topics = @[topic]) + let filter = initFilter(privateKey = some(privKey), topics = @[topic]) let filterId = filters.subscribeFilter(filter) notify(filters, msg) @@ -304,7 +304,7 @@ suite "Whisper filter": let msg = prepFilterTestMsg(src = some(privKey), topic = topic) var filters = initTable[string, Filter]() - let filter = newFilter(src = some(privKey.getPublicKey()), + let filter = initFilter(src = some(privKey.getPublicKey()), topics = @[topic]) let filterId = filters.subscribeFilter(filter) @@ -328,9 +328,9 @@ suite "Whisper filter": var filters = initTable[string, Filter]() let filterId1 = filters.subscribeFilter( - newFilter(topics = @[topic], powReq = 0.014492753623188406)) + initFilter(topics = @[topic], powReq = 0.014492753623188406)) filterId2 = filters.subscribeFilter( - newFilter(topics = @[topic], powReq = 0.014492753623188407)) + initFilter(topics = @[topic], powReq = 0.014492753623188407)) notify(filters, msg) @@ -347,8 +347,8 @@ suite "Whisper filter": var filters = initTable[string, Filter]() let - filterId1 = filters.subscribeFilter(newFilter(topics = @[topic1])) - filterId2 = filters.subscribeFilter(newFilter(topics = @[topic2])) + filterId1 = filters.subscribeFilter(initFilter(topics = @[topic1])) + filterId2 = filters.subscribeFilter(initFilter(topics = @[topic2])) notify(filters, msg) diff --git a/tests/p2p/test_shh_connect.nim b/tests/p2p/test_shh_connect.nim index 913712b..602acaa 100644 --- a/tests/p2p/test_shh_connect.nim +++ b/tests/p2p/test_shh_connect.nim @@ -59,17 +59,17 @@ suite "Whisper connections": # Filters # filter for encrypted asym - filters.add(node1.subscribeFilter(newFilter(privateKey = some(encryptKeyPair.seckey), + filters.add(node1.subscribeFilter(initFilter(privateKey = some(encryptKeyPair.seckey), topics = @[topic]), handler1)) # filter for encrypted asym + signed - filters.add(node1.subscribeFilter(newFilter(some(signKeyPair.pubkey), + filters.add(node1.subscribeFilter(initFilter(some(signKeyPair.pubkey), privateKey = some(encryptKeyPair.seckey), topics = @[topic]), handler2)) # filter for encrypted sym - filters.add(node1.subscribeFilter(newFilter(symKey = some(symKey), + filters.add(node1.subscribeFilter(initFilter(symKey = some(symKey), topics = @[topic]), handler3)) # filter for encrypted sym + signed - filters.add(node1.subscribeFilter(newFilter(some(signKeyPair.pubkey), + filters.add(node1.subscribeFilter(initFilter(some(signKeyPair.pubkey), symKey = some(symKey), topics = @[topic]), handler4)) # Messages @@ -113,8 +113,8 @@ suite "Whisper connections": check msg.decoded.payload == payloads[1] futures[1].complete(1) - var filter1 = node1.subscribeFilter(newFilter(topics = @[topic1]), handler1) - var filter2 = node1.subscribeFilter(newFilter(topics = @[topic2]), handler2) + var filter1 = node1.subscribeFilter(initFilter(topics = @[topic1]), handler1) + var filter2 = node1.subscribeFilter(initFilter(topics = @[topic2]), handler2) check: node2.postMessage(ttl = safeTTL + 1, topic = topic1, @@ -142,9 +142,9 @@ suite "Whisper connections": check msg.decoded.payload == payload futures[1].complete(1) - var filter1 = node1.subscribeFilter(newFilter(topics = @[topic], powReq = 0), + var filter1 = node1.subscribeFilter(initFilter(topics = @[topic], powReq = 0), handler1) - var filter2 = node1.subscribeFilter(newFilter(topics = @[topic], + var filter2 = node1.subscribeFilter(initFilter(topics = @[topic], powReq = 1_000_000), handler2) check: @@ -163,7 +163,7 @@ suite "Whisper connections": let topic = [byte 0, 0, 0, 0] let payload = repeat(byte 0, 10) - var filter = node1.subscribeFilter(newFilter(topics = @[topic])) + var filter = node1.subscribeFilter(initFilter(topics = @[topic])) for i in countdown(10, 1): check node2.postMessage(ttl = safeTTL, topic = topic, payload = payload) == true @@ -179,7 +179,7 @@ suite "Whisper connections": asyncTest "Local filter notify": let topic = [byte 0, 0, 0, 0] - var filter = node1.subscribeFilter(newFilter(topics = @[topic])) + var filter = node1.subscribeFilter(initFilter(topics = @[topic])) check: node1.postMessage(ttl = safeTTL, topic = topic, payload = repeat(byte 4, 10)) == true @@ -198,7 +198,7 @@ suite "Whisper connections": proc handler(msg: ReceivedMessage) = check msg.decoded.payload == payload f.complete(1) - var filter = node1.subscribeFilter(newFilter(topics = filterTopics), handler) + var filter = node1.subscribeFilter(initFilter(topics = filterTopics), handler) await node1.setBloomFilter(node1.filtersToBloom()) check: @@ -279,7 +279,7 @@ suite "Whisper connections": check msg.decoded.payload == repeat(byte 4, 10) f.complete(1) - var filter = node1.subscribeFilter(newFilter(topics = @[topic], + var filter = node1.subscribeFilter(initFilter(topics = @[topic], allowP2P = true), handler) check: node1.setPeerTrusted(toNodeId(node2.keys.pubkey)) == true diff --git a/tests/p2p/test_waku_bridge.nim b/tests/p2p/test_waku_bridge.nim index 44ffc06..cb7d654 100644 --- a/tests/p2p/test_waku_bridge.nim +++ b/tests/p2p/test_waku_bridge.nim @@ -54,9 +54,9 @@ suite "Waku - Whisper bridge tests": futures[1].complete(1) var filter1 = whisper.subscribeFilter(nodeWhisper, - whisper.newFilter(topics = @[topic1]), handler1) + whisper.initFilter(topics = @[topic1]), handler1) var filter2 = waku.subscribeFilter(nodeWaku, - waku.newFilter(topics = @[topic2]), handler2) + waku.initFilter(topics = @[topic2]), handler2) check: # Message should also end up in the Whisper node its queue via the bridge diff --git a/tests/p2p/test_waku_mail.nim b/tests/p2p/test_waku_mail.nim index cfbc9e2..9c3840c 100644 --- a/tests/p2p/test_waku_mail.nim +++ b/tests/p2p/test_waku_mail.nim @@ -73,7 +73,7 @@ suite "Waku Mail Client": f.complete(1) let filter = subscribeFilter(client, - newFilter(topics = @[topic], allowP2P = true), handler) + initFilter(topics = @[topic], allowP2P = true), handler) check: client.setPeerTrusted(simpleServerNode.id)