From 60c359fe5e18e1e07ea2935ba6651241a3ea82dd Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Mon, 25 Jul 2022 13:54:10 -0400 Subject: [PATCH] chore: dns discovery docs and fix filter docs --- docs/api/dnsdisc.md | 43 +++++++++++++++++++++++++++++++++++++++++++ docs/api/filter.md | 6 ++---- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 docs/api/dnsdisc.md diff --git a/docs/api/dnsdisc.md b/docs/api/dnsdisc.md new file mode 100644 index 00000000..6f24d120 --- /dev/null +++ b/docs/api/dnsdisc.md @@ -0,0 +1,43 @@ +Discovering nodes with DNS Discovery +=== +DNS Discovery enables anyone to register an ENR tree in the TXT field of a domain name. + +ENR is the format used to store node connection details (ip, port, multiaddr, etc). + +This enables a separation of software development and operations as dApp developers can include one or several domain names to use for DNS discovery, while operators can handle the update of the dns record. + +It also enables more decentralized bootstrapping as anyone can register a domain name and publish it for others to use. + +**Pros**: +- Low latency, low resource requirements, +- Bootstrap list can be updated by editing a domain name: no code change is needed, +- Can reference to a greater list of nodes by pointing to other domain names in the code or in the ENR tree. + +**Cons**: +- Prone to censorship: domain names can be blocked, +- Limited: Static number of nodes, operators must provide their ENR to the domain owner to get their node listed. + + +## Retrieving peers +```go +package main + +import ( + "context" + "fmt" + + "github.com/status-im/go-waku/waku/v2/dnsdisc" +) + +func main() { + discoveryURL := "enrtree://AOFTICU2XWDULNLZGRMQS4RIZPAZEHYMV4FYHAPW563HNRAOERP7C@test.waku.nodes.status.im" + nodes, err := dnsdisc.RetrieveNodes(context.Background(), discoveryURL) + if err != nil { + panic(err) + } + + fmt.Println(nodes) +} +``` + +`dnsdisc.RetrieveNodes` can also accept a `WithNameserver(nameserver string)` option which can be used to specify the nameserver to use to retrieve the TXT record from the domain name \ No newline at end of file diff --git a/docs/api/filter.md b/docs/api/filter.md index c713d4fa..9c32d851 100644 --- a/docs/api/filter.md +++ b/docs/api/filter.md @@ -11,7 +11,7 @@ import ( "fmt" "github.com/status-im/go-waku/waku/v2/node" - "github.com/status-im/go-waku/waku/v2/protocol/relay" + "github.com/status-im/go-waku/waku/v2/protocol/filter" ) ... @@ -34,9 +34,7 @@ if err := wakuNode.Start(); err != nil { ### Options One of these options must be specified when instantiating a node supporting the waku relay protocol -- `WithWakuRelay(opts ...pubsub.Option)` - enables the waku relay protocol and receives an optional list of pubsub options to tune or configure the gossipsub parameters. Supported options can be seen [here](https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#Option). The recommended [parameter configuration](https://rfc.vac.dev/spec/29/) is used by default. -- `WithWakuRelayAndMinPeers(minRelayPeersToPublish int, opts ...pubsub.Option)` - enables the waku relay protocol, specifying the minimum number of peers a topic should have to send a message. It also receives an optional list of pubsub [options](https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#Option) - +- `WitWakuFilter(isFullNode, opts ...pubsub.Option)` - enables the waku filter protocol and receives an optional list of options to configure the protocol ## Adding a peer and receiving messages ```go