diff --git a/p2p/protocol/internal/circuitv1-deprecated/relay.go b/p2p/protocol/internal/circuitv1-deprecated/relay.go index 1bb7cc0d79..fcb1b5e262 100644 --- a/p2p/protocol/internal/circuitv1-deprecated/relay.go +++ b/p2p/protocol/internal/circuitv1-deprecated/relay.go @@ -197,8 +197,9 @@ func (r *Relay) Matches(addr ma.Multiaddr) bool { return err == nil } -func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) { - s, err := r.host.NewStream(ctx, id, ProtoID) +// Queries a peer for support of hop relay +func CanHop(ctx context.Context, host host.Host, id peer.ID) (bool, error) { + s, err := host.NewStream(ctx, id, ProtoID) if err != nil { return false, err } @@ -233,6 +234,10 @@ func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) { return msg.GetCode() == pb.CircuitRelay_SUCCESS, nil } +func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) { + return CanHop(ctx, r.host, id) +} + func (r *Relay) handleNewStream(s network.Stream) { log.Infof("new relay stream from: %s", s.Conn().RemotePeer())