mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 22:13:07 +00:00
RPC node info fix Makefile error fix rpc query error add rpc_node_info to scripts target hm node info -> info consistent query node ref Add info to node api update node api docs update node api doc for consistency and accuracy minor
2.6 KiB
2.6 KiB
Waku APIs
Nim API
The Nim Waku API consist of a set of methods opearting on the Waku Node object. Some of them have different arity depending on what privacy/bandwidth trade-off the consumer wants to make. These methods are:
- Init - create a node.
- Start - start a created node.
- Subscribe - to a topic or a specific content filter.
- Unsubscribe - to a topic or a specific content filter.
- Publish - to a topic, or a topic and a specific content filter.
- Query - for historical messages.
- Info - to get information about the node.
proc init*(T: type WakuNode, nodeKey: crypto.PrivateKey,
bindIp: ValidIpAddress, bindPort: Port,
extIp = none[ValidIpAddress](), extPort = none[Port](), topics = newSeq[string]()): T =
## Creates a Waku Node.
##
## Status: Implemented.
proc start*(node: WakuNode) {.async.} =
## Starts a created Waku Node.
##
## Status: Implemented.
proc subscribe*(node: WakuNode, topic: Topic, handler: TopicHandler) {.async.} =
## Subscribes to a PubSub topic. Triggers handler when receiving messages on
## this topic. TopicHandler is a method that takes a topic and some data.
##
## NOTE The data field SHOULD be decoded as a WakuMessage.
## Status: Implemented.
proc subscribe*(node: WakuNode, request: FilterRequest, handler: ContentFilterHandler) {.async, gcsafe.} =
## Registers for messages that match a specific filter. Triggers the handler whenever a message is received.
## FilterHandler is a method that takes a MessagePush.
##
## Status: Implemented.
proc unsubscribe*(w: WakuNode, topic: Topic) =
## Unsubscribe from a topic.
##
## Status: Not yet implemented.
## TODO Implement.
proc unsubscribe*(w: WakuNode, contentFilter: ContentFilter) =
## Unsubscribe from a content filter.
##
## Status: Not yet implemented.
## TODO Implement.
proc publish*(node: WakuNode, topic: Topic, message: WakuMessage) =
## Publish a `WakuMessage` to a PubSub topic. `WakuMessage` should contain a
## `contentTopic` field for light node functionality. This field may be also
## be omitted.
##
## Status: Implemented.
proc query*(w: WakuNode, query: HistoryQuery, handler: QueryHandlerFunc) {.async, gcsafe.} =
## Queries known nodes for historical messages. Triggers the handler whenever a response is received.
## QueryHandlerFunc is a method that takes a HistoryResponse.
##
## Status: Implemented.
proc info*(node: WakuNode): WakuInfo =
## Returns information about the Node, such as what multiaddress it can be reached at.
##
## Status: Implemented.
##
JSON RPC
TODO To specify