Skip to content

Commit 99005c5

Browse files
committed
Fixup: Move advertisement out of topic registration
1 parent ceab6f4 commit 99005c5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

go/p2p/p2p.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ func (p *p2p) RegisterHandler(topic string, handler api.Handler) {
306306
)
307307

308308
p.peerMgr.RegisterTopic(topic, minTopicPeers, totalTopicPeers)
309+
p.peerMgr.AdvertiseProtocol(topic)
309310
}
310311

311312
// Implements api.Service.
@@ -340,7 +341,7 @@ func (p *p2p) RegisterProtocolServer(srv rpc.Server) {
340341

341342
p.host.SetStreamHandler(srv.Protocol(), srv.HandleStream)
342343

343-
p.peerMgr.AdvertiseProtocol(srv.Protocol())
344+
p.peerMgr.AdvertiseProtocol(string(srv.Protocol()))
344345

345346
p.logger.Info("registered protocol server",
346347
"protocol_id", srv.Protocol(),

go/p2p/peermgmt/peermgr.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ func (m *PeerManager) RegisterProtocol(p core.ProtocolID, minPeers int, totalPee
198198
// AdvertiseProtocol starts advertising readiness to serve the specified protocol.
199199
//
200200
// This enables remote peers without existing connection to find the host node.
201-
func (m *PeerManager) AdvertiseProtocol(p core.ProtocolID) {
202-
m.discovery.startAdvertising(string(p))
201+
func (m *PeerManager) AdvertiseProtocol(p string) {
202+
m.discovery.startAdvertising(p)
203203
}
204204

205205
// RegisterTopic starts tracking and managing peers that support the given topic.
@@ -222,7 +222,6 @@ func (m *PeerManager) RegisterTopic(topic string, minPeers int, totalPeers int)
222222
}
223223

224224
m.topics[topic] = &watermark{minPeers, totalPeers}
225-
m.discovery.startAdvertising(topic)
226225

227226
m.logger.Debug("topic registered",
228227
"topic", topic,

0 commit comments

Comments
 (0)