func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) error {
	n, ok := h.Network().(tpt.Network)
	if !ok {
		return fmt.Errorf("%v is not a transport network", h.Network())
	}

	r, err := NewRelay(ctx, h, upgrader, opts...)
	if err != nil {
		return err
	}

	// There's no nice way to handle these errors as we have no way to tear
	// down the relay.
	// TODO
	if err := n.AddTransport(r.Transport()); err != nil {
		log.Error("failed to add relay transport:", err)
	} else if err := n.Listen(r.Listener().Multiaddr()); err != nil {
		log.Error("failed to listen on relay transport:", err)
	}
	return nil
}
func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) error {
	n, ok := h.Network().(tpt.Network)
	if !ok {
		return fmt.Errorf("%v is not a transport network", h.Network())
	}

	r, err := NewRelay(ctx, h, upgrader, opts...)
	if err != nil {
		return err
	}

	
	
	
	if err := n.AddTransport(r.Transport()); err != nil {
		log.Error("failed to add relay transport:", err)
	} else if err := n.Listen(r.Listener().Multiaddr()); err != nil {
		log.Error("failed to listen on relay transport:", err)
	}
	return nil
}
func AddRelayTransport ( ctx context . Context , h host . Host , upgrader * tptu . Upgrader , opts ... RelayOpt ) error { n , ok := h . Network ( ) . ( tpt . Network ) if ! ok { return fmt . Errorf ( " " , h . Network ( ) ) } r , err := NewRelay ( ctx , h , upgrader , opts ... ) if err != nil { return err } // There's no nice way to handle these errors as we have no way to tear // down the relay. // TODO if err := n . AddTransport ( r . Transport ( ) ) ; err != nil { log . Error ( " " , err ) } else if err := n . Listen ( r . Listener ( ) . Multiaddr ( ) ) ; err != nil { log . Error ( " " , err ) } return nil }
// AddRelayTransport constructs a relay and adds it as a transport to the host network.
AddRelayTransport constructs a relay and adds it as a transport to the host network .