chore: dns discovery docs and fix filter docs

This commit is contained in:
Richard Ramos 2022-07-25 13:54:10 -04:00
parent 6043f6db2e
commit 60c359fe5e
No known key found for this signature in database
GPG Key ID: BD36D48BC9FFC88C
2 changed files with 45 additions and 4 deletions

43
docs/api/dnsdisc.md Normal file
View File

@ -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

View File

@ -11,7 +11,7 @@ import (
"fmt" "fmt"
"github.com/status-im/go-waku/waku/v2/node" "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 ### Options
One of these options must be specified when instantiating a node supporting the waku relay protocol 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. - `WitWakuFilter(isFullNode, opts ...pubsub.Option)` - enables the waku filter protocol and receives an optional list of options to configure the protocol
- `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)
## Adding a peer and receiving messages ## Adding a peer and receiving messages
```go ```go