-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Limited Relays #1058
Integrate Limited Relays #1058
Conversation
For some reason, the compilation complains that it can't find the |
|
config/config.go
Outdated
@@ -25,8 +25,7 @@ import ( | |||
|
|||
autonat "github.com/libp2p/go-libp2p-autonat" | |||
blankhost "github.com/libp2p/go-libp2p-blankhost" | |||
circuit "github.com/libp2p/go-libp2p-circuit" | |||
discovery "github.com/libp2p/go-libp2p-discovery" | |||
circuitv2client "github.com/libp2p/go-libp2p-circuit/v2/client" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a huge name; just circuitv2
will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even just circuit
will do in fact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
config/config.go
Outdated
@@ -92,7 +90,7 @@ type Config struct { | |||
|
|||
EnableAutoRelay bool | |||
AutoNATConfig | |||
StaticRelays []peer.AddrInfo | |||
StaticV2Relays []peer.AddrInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to rename this variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
p2p/host/relay/autorelay.go
Outdated
} | ||
// These are the known PL-operated V2 relays | ||
// TODO Fill this up | ||
var DefaultV2Relays = []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just DefaultRelays
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
p2p/host/relay/autorelay.go
Outdated
@@ -196,16 +191,13 @@ func (ar *AutoRelay) tryRelay(ctx context.Context, pi peer.AddrInfo) bool { | |||
return false | |||
} | |||
|
|||
ok, err := circuit.CanHop(ctx, ar.host, pi.ID) | |||
rsv, err := circuitv2client.Reserve(ctx, ar.host, pi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just circuit
no need for comically long names. Also, rsv
should be rsvp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
p2p/host/relay/autorelay.go
Outdated
// not a hop relay | ||
return false | ||
} | ||
ar.host.Peerstore().AddAddrs(pi.ID, rsv.Relay.Addrs, peerstore.ConnectedAddrTTL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this has changed in the v2 code.
The addresses that you get are your own relay addresses, and they are in the rsv(p).Addrs
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to schedule reservation refresh, use the Expiration
field in the reservation to make the determination.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
if rsvp.LimitDuration > MinTTLRefresh { | ||
info.resfreshAt = time.Now().Add(rsvp.LimitDuration / 2) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is completely wrong -- the limit duration is the actual relay limit; you want to look at the Expiration
which is when your reservation expires.
if rsvp.LimitDuration > MinTTLRefresh { | ||
rinfo.resfreshAt = time.Now().Add(rsvp.LimitDuration / 2) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here.
closing as we'll have to do this in pieces, and probably have a transition period for autorelay where we support both. |
For #1039