koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

Separate p2p topic specifically for peer exchange #62

Closed theoreticalbts closed 3 years ago

theoreticalbts commented 3 years ago

Participation in peer exchange (PEX) is on a per-topic basis. We want to get PEX peers but not transactions or blocks in some relatively common situations (e.g. spinning up a brand-new node, or restarting an outdated node after hours of downtime).

The best way to implement this is to create a new topic, parallel to blocks and transactions, specifically for PEX.


This PEX topic would then somehow sync its peers.

https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#Topic.ListPeers

This function looks promising.

https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#PubSubRouter

If this router can be used, it has events when a peer is added or removed, so this also might be of use.

https://github.com/libp2p/go-libp2p-discovery

This library also exists for the express purpose of peer discovery. This may be the more correct method.