diff --git a/nodebuilder/share/p2p_constructors.go b/nodebuilder/share/p2p_constructors.go index b02ea1a49e..a7efbc10cb 100644 --- a/nodebuilder/share/p2p_constructors.go +++ b/nodebuilder/share/p2p_constructors.go @@ -26,9 +26,9 @@ const ( // discovery service. archivalNodesTag = "archival" - // discovery version is a prefix for all tags used in discovery. It is bumped when - // there are protocol breaking changes. - version = "v0.1.0" + // protocolVersion is a prefix for all tags used in discovery. It is bumped when + // there are protocol breaking changes to prevent new software version to discover older versions. + protocolVersion = "v0.1.0" ) // TODO @renaynay: rename @@ -85,8 +85,8 @@ func fullDiscoveryAndPeerManager(tp node.Type, cfg *Config) fx.Option { cfg.Discovery, host, disc, - version, fullNodesTag, + protocolVersion, discOpts..., ) if err != nil { @@ -133,7 +133,7 @@ func archivalDiscoveryAndPeerManager(tp node.Type, cfg *Config) fx.Option { cfg.Discovery, h, disc, - version, + protocolVersion, archivalNodesTag, discOpts..., ) diff --git a/share/shwap/p2p/discovery/discovery.go b/share/shwap/p2p/discovery/discovery.go index 54a6e4dd10..7736cbe3b6 100644 --- a/share/shwap/p2p/discovery/discovery.go +++ b/share/shwap/p2p/discovery/discovery.go @@ -77,12 +77,15 @@ func (f OnUpdatedPeers) add(next OnUpdatedPeers) OnUpdatedPeers { } // NewDiscovery constructs a new discovery. +// It accepts tag which is a rendezvous point/topic for peers +// to advertise and discover each other. Tag suffix is used to create +// subnetworks within a tag, e.g. for different protocol versions yet running +// over the same p2p network. func NewDiscovery( params *Parameters, h host.Host, d discovery.Discovery, - prefix string, - tag string, + tag, tagSuffix string, opts ...Option, ) (*Discovery, error) { if err := params.Validate(); err != nil { @@ -95,7 +98,7 @@ func NewDiscovery( o := newOptions(opts...) return &Discovery{ tag: tag, - topic: fmt.Sprintf("/%s/%s", prefix, tag), + topic: fmt.Sprintf("/%s/%s", tag, tagSuffix), set: newLimitedSet(params.PeersLimit), host: h, disc: d,