func newProtocolHandler(ctx context.Context, id protocol.ID, maxPeers int, minPeers int, host *HostNode, connManager *ConnectionManager, disc discovery.Discovery) *ProtocolHandler {
	ph := &ProtocolHandler{
		ID:               id,
		MaximumPeers:     maxPeers,
		MinimumPeers:     minPeers,
		discovery:        disc,
		host:             host,
		messageHandlers:  make(map[string]MessageHandler),
		outgoingMessages: make(map[peer.ID]chan proto.Message),
		connManager:      connManager,
		ctx:              ctx,
		notifees:         make([]ConnectionManagerNotifee, 0),
	}

	host.setStreamHandler(id, ph.handleStream)

	go ph.findPeers()

	go ph.advertise()

	return ph
}
// newProtocolHandler constructs a new protocol handler for a specific protocol ID.
newProtocolHandler constructs a new protocol handler for a specific protocol ID.
// newProtocolHandler constructs a new protocol handler for a specific protocol ID .
func newProtocolHandler(ctx context.Context, id protocol.ID, maxPeers int, minPeers int, host *HostNode, connManager *ConnectionManager, disc discovery.Discovery) *ProtocolHandler {
	ph := &ProtocolHandler{
		ID:               id,
		MaximumPeers:     maxPeers,
		MinimumPeers:     minPeers,
		discovery:        disc,
		host:             host,
		messageHandlers:  make(map[string]MessageHandler),
		outgoingMessages: make(map[peer.ID]chan proto.Message),
		connManager:      connManager,
		ctx:              ctx,
		notifees:         make([]ConnectionManagerNotifee, 0),
	}
	host.setStreamHandler(id, ph.handleStream)
	go ph.findPeers()
	go ph.advertise()
	return ph
}
func newProtocolHandler ( ctx context . Context , id protocol . ID , maxPeers int , minPeers int , host * HostNode , connManager * ConnectionManager , disc discovery . Discovery ) * ProtocolHandler { ph := & ProtocolHandler { ID : id , MaximumPeers : maxPeers , MinimumPeers : minPeers , discovery : disc , host : host , messageHandlers : make ( map [ string ] MessageHandler ) , outgoingMessages : make ( map [ peer . ID ] chan proto . Message ) , connManager : connManager , ctx : ctx , notifees : make ( [ ] ConnectionManagerNotifee , 0 ) , } host . setStreamHandler ( id , ph . handleStream ) go ph . findPeers ( ) go ph . advertise ( ) return ph }
newProtocolHandler constructs a new protocol handler for a specific protocol ID.
newProtocolHandler constructs a new protocol handler for a specific protocol ID .