Skip to content

Commit

Permalink
chore(node): waku node code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Delgado authored Oct 27, 2022
1 parent bccb73c commit 0725da0
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 267 deletions.
2 changes: 1 addition & 1 deletion apps/chat2/chat2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Chat = ref object

type
PrivateKey* = crypto.PrivateKey
Topic* = waku_node.Topic
Topic* = waku_node.PubsubTopic

#####################
## chat2 protobufs ##
Expand Down
4 changes: 2 additions & 2 deletions apps/wakubridge/wakubridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type
WakuBridge* = ref object of RootObj
nodev1*: EthereumNode
nodev2*: WakuNode
nodev2PubsubTopic: waku_node.Topic # Pubsub topic to bridge to/from
nodev2PubsubTopic: waku_node.PubsubTopic # Pubsub topic to bridge to/from
seen: seq[hashes.Hash] # FIFO queue of seen WakuMessages. Used for deduplication.
rng: ref HmacDrbgContext
v1Pool: seq[Node] # Pool of v1 nodes for possible connections
Expand Down Expand Up @@ -228,7 +228,7 @@ proc new*(T: type WakuBridge,
nodev2ExtIp = none[ValidIpAddress](), nodev2ExtPort = none[Port](),
nameResolver: NameResolver = nil,
# Bridge configuration
nodev2PubsubTopic: waku_node.Topic,
nodev2PubsubTopic: waku_node.PubsubTopic,
v1Pool: seq[Node] = @[],
targetV1Peers = 0): T
{.raises: [Defect,IOError, TLSStreamProtocolError, LPError].} =
Expand Down
4 changes: 2 additions & 2 deletions examples/v2/basic2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ proc runBackground() {.async.} =
await node.mountRelay()

# Subscribe to a topic
let topic = cast[Topic]("foobar")
proc handler(topic: Topic, data: seq[byte]) {.async, gcsafe.} =
let topic = cast[PubsubTopic]("foobar")
proc handler(topic: PubsubTopic, data: seq[byte]) {.async, gcsafe.} =
let message = WakuMessage.init(data).value
let payload = cast[string](message.payload)
info "Hit subscribe handler", topic=topic, payload=payload, contentTopic=message.contentTopic
Expand Down
Loading

0 comments on commit 0725da0

Please sign in to comment.