Introduce WakuMode

This commit is contained in:
kdeme 2019-12-13 17:04:08 +01:00 committed by zah
parent 7b80b313e4
commit c3aeb15ce5
3 changed files with 31 additions and 4 deletions

View File

@ -270,6 +270,18 @@ proc setupWakuRPC*(node: EthereumNode, keys: WhisperKeys, rpcsrv: RpcServer) =
result = node.subscribeFilter(filter).Identifier result = node.subscribeFilter(filter).Identifier
# TODO: Should we do this here "automatically" or separate it in another
# RPC call? Is there a use case for that?
# Same could be said about bloomfilter, except that there is a use case
# there to have a full node no matter what message filters.
let config = node.protocolState(Waku).config
if config.wakuMode == WakuChan:
try:
# TODO: an addTopics call would probably more useful
waitFor node.setTopics(config.topics.concat(filter.topics))
except CatchableError:
trace "setTopics error occured"
rpcsrv.rpc("shh_deleteMessageFilter") do(id: Identifier) -> bool: rpcsrv.rpc("shh_deleteMessageFilter") do(id: Identifier) -> bool:
## Uninstall a message filter in the node. ## Uninstall a message filter in the node.
## ##

View File

@ -1,5 +1,6 @@
import import
confutils/defs, chronicles, eth/keys, chronos confutils/defs, chronicles, chronos,
eth/keys, eth/p2p/rlpx_protocols/waku_protocol
type type
Fleet* = enum Fleet* = enum
@ -77,8 +78,17 @@ type
desc: "Enable Waku RPC server", desc: "Enable Waku RPC server",
name: "rpc-binds" }: seq[string] name: "rpc-binds" }: seq[string]
wakuMode* {.
desc: "Select the Waku mode",
defaultValue: WakuSan
name: "waku-mode" }: WakuMode
wakuPow* {.
desc: "PoW requirement of Waku node",
defaultValue: 0.002
name: "waku-pow" }: float64
# TODO: # TODO:
# - Waku / Whisper config such as PoW, Waku Mode, bloom, etc.
# - nat # - nat
# - metrics # - metrics
# - discv5 + topic register # - discv5 + topic register

View File

@ -37,8 +37,13 @@ proc run(config: WakuNodeConf) =
addAllCapabilities = false) addAllCapabilities = false)
if not config.bootnodeOnly: if not config.bootnodeOnly:
node.addCapability Waku # Always enable Waku protocol node.addCapability Waku # Always enable Waku protocol
# TODO: make this configurable let wakuConfig = WakuConfig(powRequirement: config.wakuPow,
node.protocolState(Waku).config.powRequirement = 0.002 bloom: fullBloom(),
isLightNode: false,
maxMsgSize: waku_protocol.defaultMaxMsgSize,
wakuMode: config.wakuMode,
topics: @[])
node.configureWaku(wakuConfig)
if config.whisper or config.whisperBridge: if config.whisper or config.whisperBridge:
node.addCapability Whisper node.addCapability Whisper
node.protocolState(Whisper).config.powRequirement = 0.002 node.protocolState(Whisper).config.powRequirement = 0.002