func NewConnectionManager(ctx context.Context, host *HostNode, discoveryOptions ConnectionManagerOptions) (*ConnectionManager, error) {
	routing, err := kaddht.New(ctx, host.GetHost(), dhtopts.Protocols(
		protocol.ID(DHTProtocolID),
	))

	go func() {
		for _, addr := range discoveryOptions.BootstrapAddresses {
			host.Connect(context.Background(), addr)
		}
	}()

	if err != nil {
		return nil, err
	}
	var bootstrapConfig = kaddht.BootstrapConfig{
		Queries: 5,
		Period:  time.Duration(5 * time.Minute),
		Timeout: time.Duration(10 * time.Second),
	}
	if err = routing.BootstrapWithConfig(ctx, bootstrapConfig); err != nil {
		return nil, err
	}
	return &ConnectionManager{
		host:                  host,
		ctx:                   ctx,
		Options:               discoveryOptions,
		p2pDiscovery:          routingdiscovery.NewRoutingDiscovery(routing),
		protocolConfiguration: make(map[protocol.ID]*ProtocolHandler),
		lastConnect:           make(map[peer.ID]time.Time),
	}, nil
}
// NewConnectionManager creates a new discovery service.
NewConnectionManager creates a new discovery service.
// NewConnectionManager creates a new discovery service .
func NewConnectionManager(ctx context.Context, host *HostNode, discoveryOptions ConnectionManagerOptions) (*ConnectionManager, error) {
	routing, err := kaddht.New(ctx, host.GetHost(), dhtopts.Protocols(
		protocol.ID(DHTProtocolID),
	))
	go func() {
		for _, addr := range discoveryOptions.BootstrapAddresses {
			host.Connect(context.Background(), addr)
		}
	}()
	if err != nil {
		return nil, err
	}
	var bootstrapConfig = kaddht.BootstrapConfig{
		Queries: 5,
		Period:  time.Duration(5 * time.Minute),
		Timeout: time.Duration(10 * time.Second),
	}
	if err = routing.BootstrapWithConfig(ctx, bootstrapConfig); err != nil {
		return nil, err
	}
	return &ConnectionManager{
		host:                  host,
		ctx:                   ctx,
		Options:               discoveryOptions,
		p2pDiscovery:          routingdiscovery.NewRoutingDiscovery(routing),
		protocolConfiguration: make(map[protocol.ID]*ProtocolHandler),
		lastConnect:           make(map[peer.ID]time.Time),
	}, nil
}
func NewConnectionManager ( ctx context . Context , host * HostNode , discoveryOptions ConnectionManagerOptions ) ( * ConnectionManager , error ) { routing , err := kaddht . New ( ctx , host . GetHost ( ) , dhtopts . Protocols ( protocol . ID ( DHTProtocolID ) , ) ) go func ( ) { for _ , addr := range discoveryOptions . BootstrapAddresses { host . Connect ( context . Background ( ) , addr ) } } ( ) if err != nil { return nil , err } var bootstrapConfig = kaddht . BootstrapConfig { Queries : 5 , Period : time . Duration ( 5 * time . Minute ) , Timeout : time . Duration ( 10 * time . Second ) , } if err = routing . BootstrapWithConfig ( ctx , bootstrapConfig ) ; err != nil { return nil , err } return & ConnectionManager { host : host , ctx : ctx , Options : discoveryOptions , p2pDiscovery : routingdiscovery . NewRoutingDiscovery ( routing ) , protocolConfiguration : make ( map [ protocol . ID ] * ProtocolHandler ) , lastConnect : make ( map [ peer . ID ] time . Time ) , } , nil }
NewConnectionManager creates a new discovery service.
NewConnectionManager creates a new discovery service .