mirror of
https://github.com/logos-messaging/go-waku-rendezvous.git
synced 2026-01-05 22:53:07 +00:00
chore: update rendezvous documentation
This commit is contained in:
parent
292f29fd18
commit
b0065d5318
133
README.md
133
README.md
@ -1,10 +1,129 @@
|
||||
Rendezvous
|
||||
=================
|
||||
# Rendezvous Protocol
|
||||
|
||||
#### What is this?
|
||||
### Overview
|
||||
|
||||
Similar to status-im/rendezvous in using a smaller liveness TTL for records (20s), and not using UNREGISTER REQUEST,
|
||||
due to assuming that the TTL is very low (making it incompatible with libp2p original rendezvous spec). This module
|
||||
is intended to be used in go-waku as a ambient peer discovery mechanism.
|
||||
Similar to [status-im/rendezvous](https://github.com/status-im/rendezvous)
|
||||
in using a smaller liveness TTL for records (20s), and not using `UNREGISTER
|
||||
REQUEST`, due to assuming that the TTL is very low (making it incompatible
|
||||
with libp2p original rendezvous spec). This module is intended to be used
|
||||
in go-waku as a lightweight mechanism for generalized peer discovery.
|
||||
|
||||
This module uses protobuffers instead of RLP, and does not use ENR ([Ethereum Node Records](https://eips.ethereum.org/EIPS/eip-778))
|
||||
Another difference compared to [libp2p/rendezvous](https://github.com/libp2p/specs/blob/master/rendezvous/README.md) and status-im/rendezvous is the usage of [routing records](https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md) and [signed envelopes](https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md)
|
||||
|
||||
**Protocol identifier**: `/vac/waku/rendezvous/0.0.1`
|
||||
|
||||
### Usage
|
||||
|
||||
**Adding discovery to gossipsub**
|
||||
```go
|
||||
import (
|
||||
"github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
pubsub "github.com/status-im/go-libp2p-pubsub"
|
||||
rendezvous "github.com/status-im/go-waku-rendezvous"
|
||||
)
|
||||
|
||||
// create a new libp2p Host that listens on a random TCP port
|
||||
h, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Create a rendezvous instance
|
||||
rendezvous := rendezvous.NewRendezvousDiscovery(h)
|
||||
|
||||
// create a new PubSub service using the GossipSub router
|
||||
ps, err := pubsub.NewGossipSub(ctx, h, pubsub.WithDiscovery(rendezvous))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
**Creating a rendezvous server**
|
||||
```go
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
pubsub "github.com/status-im/go-libp2p-pubsub"
|
||||
rendezvous "github.com/status-im/go-waku-rendezvous"
|
||||
)
|
||||
|
||||
// create a new libp2p Host that listens on a random TCP port
|
||||
h, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// LevelDB storage for peer records
|
||||
db, err := leveldb.OpenFile("/tmp/rendezvous", &opt.Options{OpenFilesCacheCapacity: 3})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
storage := rendezvous.NewStorage(db)
|
||||
|
||||
rendezvousService = rendezvous.NewRendezvousService(h, storage)
|
||||
if err := rendezvousService.Start(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
### Protobuf
|
||||
|
||||
- [record.pb.Envelope](https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md#wire-format)
|
||||
- [PeerRecord protobuffer](https://github.com/libp2p/specs/blob/master/RFC/0003-routing-records.md#address-record-format)
|
||||
|
||||
```protobuf
|
||||
message Message {
|
||||
enum MessageType {
|
||||
REGISTER = 0;
|
||||
REGISTER_RESPONSE = 1;
|
||||
DISCOVER = 2;
|
||||
DISCOVER_RESPONSE = 3;
|
||||
}
|
||||
|
||||
enum ResponseStatus {
|
||||
OK = 0;
|
||||
E_INVALID_NAMESPACE = 100;
|
||||
E_INVALID_PEER_INFO = 101;
|
||||
E_INVALID_TTL = 102;
|
||||
E_NOT_AUTHORIZED = 200;
|
||||
E_INTERNAL_ERROR = 300;
|
||||
E_UNAVAILABLE = 400;
|
||||
}
|
||||
|
||||
message Register {
|
||||
string ns = 1;
|
||||
record.pb.Envelope peer = 2;
|
||||
int64 ttl = 3; // in seconds
|
||||
}
|
||||
|
||||
message RegisterResponse {
|
||||
ResponseStatus status = 1;
|
||||
string statusText = 2;
|
||||
int64 ttl = 3;
|
||||
}
|
||||
|
||||
message Discover {
|
||||
string ns = 1;
|
||||
int64 limit = 2;
|
||||
}
|
||||
|
||||
message DiscoverResponse {
|
||||
repeated Register registrations = 1;
|
||||
ResponseStatus status = 3;
|
||||
string statusText = 4;
|
||||
}
|
||||
|
||||
MessageType type = 1;
|
||||
Register register = 2;
|
||||
RegisterResponse registerResponse = 3;
|
||||
Discover discover = 4;
|
||||
DiscoverResponse discoverResponse = 5;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@ -28,25 +28,22 @@ type Message_MessageType int32
|
||||
const (
|
||||
Message_REGISTER Message_MessageType = 0
|
||||
Message_REGISTER_RESPONSE Message_MessageType = 1
|
||||
Message_UNREGISTER Message_MessageType = 2
|
||||
Message_DISCOVER Message_MessageType = 3
|
||||
Message_DISCOVER_RESPONSE Message_MessageType = 4
|
||||
Message_DISCOVER Message_MessageType = 2
|
||||
Message_DISCOVER_RESPONSE Message_MessageType = 3
|
||||
)
|
||||
|
||||
var Message_MessageType_name = map[int32]string{
|
||||
0: "REGISTER",
|
||||
1: "REGISTER_RESPONSE",
|
||||
2: "UNREGISTER",
|
||||
3: "DISCOVER",
|
||||
4: "DISCOVER_RESPONSE",
|
||||
2: "DISCOVER",
|
||||
3: "DISCOVER_RESPONSE",
|
||||
}
|
||||
|
||||
var Message_MessageType_value = map[string]int32{
|
||||
"REGISTER": 0,
|
||||
"REGISTER_RESPONSE": 1,
|
||||
"UNREGISTER": 2,
|
||||
"DISCOVER": 3,
|
||||
"DISCOVER_RESPONSE": 4,
|
||||
"DISCOVER": 2,
|
||||
"DISCOVER_RESPONSE": 3,
|
||||
}
|
||||
|
||||
func (x Message_MessageType) String() string {
|
||||
@ -433,42 +430,41 @@ func init() {
|
||||
func init() { proto.RegisterFile("rendezvous.proto", fileDescriptor_ef0a1d5737df1c36) }
|
||||
|
||||
var fileDescriptor_ef0a1d5737df1c36 = []byte{
|
||||
// 551 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x4c,
|
||||
0x14, 0xcd, 0xd8, 0x69, 0xbe, 0xf4, 0xf6, 0x4b, 0x34, 0x9d, 0x52, 0x11, 0x65, 0x11, 0xaa, 0x48,
|
||||
0xa8, 0x5d, 0xa5, 0xa8, 0x48, 0x6c, 0x10, 0x0b, 0xb7, 0x19, 0xc0, 0x22, 0xb5, 0xa3, 0x6b, 0x27,
|
||||
0x0b, 0x36, 0x56, 0xd2, 0x0c, 0x91, 0xa5, 0x60, 0x5b, 0x1e, 0x37, 0xa2, 0x6c, 0x79, 0x01, 0x96,
|
||||
0xec, 0x78, 0x01, 0x1e, 0x00, 0xf1, 0x04, 0x5d, 0xf2, 0x08, 0x28, 0xbc, 0x08, 0xf2, 0x6f, 0xf3,
|
||||
0x43, 0x0b, 0x12, 0xab, 0xcc, 0xbd, 0x73, 0xce, 0xc9, 0xb9, 0xe7, 0xda, 0x06, 0x1a, 0x0a, 0x6f,
|
||||
0x22, 0xde, 0xcf, 0xfd, 0x4b, 0xd9, 0x09, 0x42, 0x3f, 0xf2, 0x59, 0x6d, 0xb9, 0x33, 0x6e, 0x36,
|
||||
0x42, 0x71, 0xe1, 0x87, 0x93, 0xe3, 0x60, 0x7c, 0x2c, 0xbc, 0xb9, 0x98, 0xf9, 0x81, 0x48, 0x81,
|
||||
0xed, 0x6f, 0x55, 0xf8, 0xef, 0x5c, 0x48, 0x39, 0x9a, 0x0a, 0xf6, 0x04, 0xca, 0xd1, 0x55, 0x20,
|
||||
0x1a, 0xe4, 0x80, 0x1c, 0xd5, 0x4f, 0xda, 0x9d, 0x15, 0x8d, 0x4e, 0x86, 0xca, 0x7f, 0xed, 0xab,
|
||||
0x40, 0x60, 0x82, 0x67, 0x4f, 0xa1, 0x1a, 0x8a, 0xa9, 0x2b, 0x23, 0x11, 0x36, 0x94, 0x03, 0x72,
|
||||
0xb4, 0x73, 0xf2, 0xe0, 0x16, 0x2e, 0x66, 0x30, 0x2c, 0x08, 0xcc, 0x8a, 0xdd, 0x67, 0x5d, 0x21,
|
||||
0x03, 0xdf, 0x93, 0xa2, 0xa1, 0x26, 0x22, 0x87, 0x7f, 0x12, 0xc9, 0xe0, 0xb8, 0x21, 0x10, 0x3b,
|
||||
0x9a, 0xb8, 0xf2, 0xc2, 0x9f, 0x8b, 0xb0, 0x51, 0xbe, 0xd3, 0x51, 0x37, 0x83, 0x61, 0x41, 0x88,
|
||||
0x1d, 0xe5, 0xe7, 0xc2, 0xd1, 0xd6, 0x9d, 0x8e, 0xba, 0x6b, 0x70, 0xdc, 0x10, 0x68, 0x0e, 0xa0,
|
||||
0x9a, 0xfb, 0x66, 0x75, 0x50, 0x3c, 0x99, 0xa4, 0xbc, 0x8d, 0x8a, 0x27, 0xd9, 0x21, 0x94, 0x03,
|
||||
0x51, 0x64, 0xb7, 0xd7, 0x49, 0x97, 0x15, 0xff, 0x01, 0xcf, 0x96, 0x85, 0x09, 0x80, 0x51, 0x50,
|
||||
0xa3, 0x68, 0x96, 0xc4, 0xa3, 0x62, 0x7c, 0x6c, 0x7e, 0x20, 0x40, 0xd7, 0xf3, 0x60, 0xcf, 0xa0,
|
||||
0x22, 0xa3, 0x51, 0x74, 0x29, 0xb3, 0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xf4, 0x0d, 0xdb, 0x07, 0xca, 0x1d, 0xc3, 0xb4, 0x1d, 0x6d, 0x60, 0xbf,
|
||||
0x34, 0x51, 0x7f, 0xcd, 0xbb, 0xf4, 0x9a, 0xa4, 0x6d, 0xdd, 0xb0, 0x39, 0x1a, 0x5a, 0xcf, 0xe1,
|
||||
0x88, 0x26, 0xd2, 0x2f, 0x0a, 0x63, 0xb1, 0xc0, 0xc0, 0xd0, 0x86, 0x9a, 0xde, 0xd3, 0x4e, 0x7b,
|
||||
0x9c, 0x7e, 0x54, 0x4f, 0xe9, 0xf5, 0xa2, 0x45, 0xbe, 0x2f, 0x5a, 0xe4, 0xc7, 0xa2, 0x45, 0x3e,
|
||||
0xfd, 0x6c, 0x95, 0xc6, 0x95, 0xe4, 0xab, 0xf2, 0xf8, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x08,
|
||||
0x62, 0x6b, 0xbb, 0x92, 0x04, 0x00, 0x00,
|
||||
// 543 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcb, 0x6e, 0xd3, 0x40,
|
||||
0x14, 0xcd, 0xd8, 0x69, 0x48, 0x6f, 0x49, 0x34, 0x9d, 0x52, 0x11, 0x65, 0x11, 0xaa, 0x48, 0xa8,
|
||||
0x5d, 0xa5, 0xa8, 0x48, 0x6c, 0x10, 0x0b, 0xb7, 0x19, 0xc0, 0xc2, 0xb5, 0xa3, 0x6b, 0x27, 0x48,
|
||||
0x6c, 0xac, 0xa4, 0x19, 0x2a, 0x4b, 0xc1, 0xb6, 0x3c, 0x6e, 0x44, 0xd9, 0xf2, 0x03, 0x2c, 0xd9,
|
||||
0xb1, 0x47, 0x7c, 0x00, 0x9f, 0xd0, 0x25, 0x9f, 0x80, 0xc2, 0x8f, 0x20, 0xbf, 0xd2, 0x3c, 0x68,
|
||||
0x41, 0x62, 0x95, 0xb9, 0x77, 0xce, 0x39, 0x39, 0xf7, 0x5c, 0xdb, 0x40, 0x23, 0xe1, 0x8f, 0xc5,
|
||||
0x87, 0x69, 0x70, 0x21, 0x3b, 0x61, 0x14, 0xc4, 0x01, 0xab, 0x2d, 0x76, 0x46, 0xcd, 0x46, 0x24,
|
||||
0xce, 0x82, 0x68, 0x7c, 0x18, 0x8e, 0x0e, 0x85, 0x3f, 0x15, 0x93, 0x20, 0x14, 0x19, 0xb0, 0xfd,
|
||||
0xb5, 0x0a, 0x77, 0x4e, 0x85, 0x94, 0xc3, 0x73, 0xc1, 0x9e, 0x40, 0x39, 0xbe, 0x0c, 0x45, 0x83,
|
||||
0xec, 0x91, 0x83, 0xfa, 0x51, 0xbb, 0xb3, 0xa4, 0xd1, 0xc9, 0x51, 0xc5, 0xaf, 0x73, 0x19, 0x0a,
|
||||
0x4c, 0xf1, 0xec, 0x29, 0x54, 0x23, 0x71, 0xee, 0xc9, 0x58, 0x44, 0x0d, 0x65, 0x8f, 0x1c, 0x6c,
|
||||
0x1d, 0x3d, 0xb8, 0x81, 0x8b, 0x39, 0x0c, 0xe7, 0x04, 0x66, 0x27, 0xee, 0xf3, 0xae, 0x90, 0x61,
|
||||
0xe0, 0x4b, 0xd1, 0x50, 0x53, 0x91, 0xfd, 0xbf, 0x89, 0xe4, 0x70, 0x5c, 0x13, 0x48, 0x1c, 0x8d,
|
||||
0x3d, 0x79, 0x16, 0x4c, 0x45, 0xd4, 0x28, 0xdf, 0xea, 0xa8, 0x9b, 0xc3, 0x70, 0x4e, 0x48, 0x1c,
|
||||
0x15, 0xe7, 0xb9, 0xa3, 0x8d, 0x5b, 0x1d, 0x75, 0x57, 0xe0, 0xb8, 0x26, 0xd0, 0xec, 0x43, 0xb5,
|
||||
0xf0, 0xcd, 0xea, 0xa0, 0xf8, 0x32, 0x4d, 0x79, 0x13, 0x15, 0x5f, 0xb2, 0x7d, 0x28, 0x87, 0x62,
|
||||
0x9e, 0xdd, 0x4e, 0x27, 0x5b, 0x56,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x4e, 0xb9, 0xdd, 0xd3, 0x4e, 0x38, 0x1d, 0x2f, 0x5f, 0xf4, 0x38, 0x47,
|
||||
0x57, 0x37, 0x9f, 0x5b, 0x54, 0xb0, 0x6d, 0xa8, 0x5d, 0x5f, 0x38, 0x8e, 0x41, 0xdf, 0xb2, 0x5d,
|
||||
0xa0, 0xdc, 0x35, 0x2d, 0xc7, 0xd5, 0xfa, 0xce, 0x4b, 0x0b, 0xf5, 0x37, 0xbc, 0x4b, 0xaf, 0x48,
|
||||
0xd6, 0xd6, 0x4d, 0x87, 0xa3, 0xa9, 0x19, 0x2e, 0x47, 0xb4, 0x90, 0x7e, 0x53, 0x18, 0x4b, 0x04,
|
||||
0xfa, 0xa6, 0x36, 0xd0, 0x74, 0x43, 0x3b, 0x36, 0x38, 0xfd, 0xa4, 0x1e, 0xd3, 0xab, 0x59, 0x8b,
|
||||
0xfc, 0x98, 0xb5, 0xc8, 0xcf, 0x59, 0x8b, 0x7c, 0xfe, 0xd5, 0x2a, 0x8d, 0x2a, 0xe9, 0x57, 0xe4,
|
||||
0xf1, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x12, 0xe2, 0x82, 0x67, 0x82, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Message) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
@ -8,9 +8,8 @@ message Message {
|
||||
enum MessageType {
|
||||
REGISTER = 0;
|
||||
REGISTER_RESPONSE = 1;
|
||||
UNREGISTER = 2;
|
||||
DISCOVER = 3;
|
||||
DISCOVER_RESPONSE = 4;
|
||||
DISCOVER = 2;
|
||||
DISCOVER_RESPONSE = 3;
|
||||
}
|
||||
|
||||
enum ResponseStatus {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user