Skip to content

Commit

Permalink
chore(shwap/discovery): prefix -> suffix (#3778)
Browse files Browse the repository at this point in the history
Fixes #3777
  • Loading branch information
Wondertan authored Sep 26, 2024
2 parents 98a127b + 180e06d commit ac0515f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions nodebuilder/share/p2p_constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,8 +85,8 @@ func fullDiscoveryAndPeerManager(tp node.Type, cfg *Config) fx.Option {
cfg.Discovery,
host,
disc,
version,
fullNodesTag,
protocolVersion,
discOpts...,
)
if err != nil {
Expand Down Expand Up @@ -133,7 +133,7 @@ func archivalDiscoveryAndPeerManager(tp node.Type, cfg *Config) fx.Option {
cfg.Discovery,
h,
disc,
version,
protocolVersion,
archivalNodesTag,
discOpts...,
)
Expand Down
9 changes: 6 additions & 3 deletions share/shwap/p2p/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit ac0515f

Please sign in to comment.