From bcf6ec95edcf298cf72588ff4dc69856f54458e2 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Fri, 22 May 2020 15:28:51 +0800 Subject: [PATCH] wakuPost -> wakuPublish and change sig --- waku/node/v2/quicksim.nim | 1 + waku/node/v2/rpc/wakucallsigs.nim | 2 +- waku/node/v2/rpc/wakurpc.nim | 13 +++++-------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/waku/node/v2/quicksim.nim b/waku/node/v2/quicksim.nim index e1393ed0f..326ad6822 100644 --- a/waku/node/v2/quicksim.nim +++ b/waku/node/v2/quicksim.nim @@ -35,5 +35,6 @@ waitFor node2.connect("localhost", Port(8548)) let version = waitFor node1.wakuVersion() let res = waitFor node1.wakuPost("hello world") +let res2 = waitFor node1.wakuPublish("foobar", "hello world") info "Version is", version diff --git a/waku/node/v2/rpc/wakucallsigs.nim b/waku/node/v2/rpc/wakucallsigs.nim index b7beb83ec..5d67e41f4 100644 --- a/waku/node/v2/rpc/wakucallsigs.nim +++ b/waku/node/v2/rpc/wakucallsigs.nim @@ -1,6 +1,6 @@ # Alpha - Currently implemented in v2 proc waku_version(): string -proc waku_post(message: string): bool +proc waku_publish(topic: string, message: string): bool # NYI proc waku_info(): WakuInfo diff --git a/waku/node/v2/rpc/wakurpc.nim b/waku/node/v2/rpc/wakurpc.nim index 96df9f03b..8e35c4c22 100644 --- a/waku/node/v2/rpc/wakurpc.nim +++ b/waku/node/v2/rpc/wakurpc.nim @@ -1,8 +1,6 @@ import json_rpc/rpcserver, tables, options, eth/[common, rlp, keys, p2p], - #DevP2P impl - # ../../../protocol/v1/waku_protocol, ../../../protocol/v2/waku_protocol, nimcrypto/[sysrand, hmac, sha2, pbkdf2], ../../v1/rpc/[rpc_types, hexstrings, key_storage], @@ -25,20 +23,19 @@ proc setupWakuRPC*(wakuProto: WakuProto, rpcsrv: RpcServer) = ## Returns string of the current Waku protocol version. result = WakuSubCodec - # XXX Type # TODO: Implement symkey etc logic - rpcsrv.rpc("waku_post") do(message: string) -> bool: + rpcsrv.rpc("waku_publish") do(topic: string, message: string) -> bool: let data = cast[seq[byte]](message) # Assumes someone subscribing on this topic #let wakuSub = wakuProto.switch.pubsub let wakuSub = cast[WakuSub](wakuProto.switch.pubSub.get()) # XXX also future return type - discard wakuSub.publish("foobar", data) + discard wakuSub.publish(topic, data) + return true + #if not result: + # raise newException(ValueError, "Message could not be posted") return true #if not result: # raise newException(ValueError, "Message could not be posted") - # TODO: Dial/Connect - # XXX: Though wrong layer for that - wait how does this work in devp2p sim? - # We connect to nodes there, should be very similar here