Skip to content

Commit

Permalink
Merge pull request #79 from libp2p/feat/can-hop
Browse files Browse the repository at this point in the history
expose CanHop as a module function
  • Loading branch information
vyzo committed Aug 2, 2019
2 parents e92179b + b906ca5 commit 180ea47
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions p2p/protocol/internal/circuitv1-deprecated/relay.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit 180ea47

Please sign in to comment.