-
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
relay: make only 1 reservation per peer #2974
base: master
Are you sure you want to change the base?
Conversation
We only need 1 reservation per peer. This PR also proactively removes relay reservations on disconnecting from the peer. This helps when the relay client is restarting frequently.
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.
Looks good mod some nits
} | ||
if err := c.AddReservation(p, randomIPv4Addr(t)); err != errTooManyReservationsForPeer { | ||
if err := c.Reserve(p2, ipAddr, expiry); err != errTooManyReservationsForIP { | ||
t.Fatalf("expected to run into total reservation limit, got %v", err) |
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.
The text here needs to be updated. Maybe:
"Expected to error since this ip has already been reserved by a different peer"
if err := c.Reserve(p, randomIPv4Addr(t), expiry); err != nil { | ||
t.Fatalf("expected to update reservation for peer, got %v", err) | ||
} | ||
if err := c.Reserve(p2, ipAddr, expiry); err != nil { | ||
t.Fatalf("expected reservation for different peer to be possible, got %v", err) |
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 comment here. The text probably should change.
asns: make(map[uint32][]time.Time), | ||
rc: rc, | ||
ips: make(map[string][]peerWithExpiry), | ||
asns: make(map[uint32][]peerWithExpiry), | ||
} | ||
} | ||
|
||
// AddReservation adds a reservation for a given peer with a given multiaddr. |
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.
Update doc comment
@@ -22,6 +22,8 @@ type Resources struct { | |||
|
|||
// MaxReservationsPerPeer is the maximum number of reservations originating from the same | |||
// peer; default is 4. | |||
// | |||
// Deprecated: We only need 1 reservation per peer. |
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.
Let's change the default below as well
We only need 1 reservation per peer.
This PR also proactively removes relay reservations on disconnecting from the peer. This helps when the relay client is restarting frequently.
Fixes: #2963