Skip to content
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

Replace peer addresses in identify #599

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
ids.addrMu.Lock()
switch ids.Host.Network().Connectedness(p) {
case inet.Connected:
ids.Host.Peerstore().UpdateAddrs(p, pstore.ConnectedAddrTTL, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't actually suggesting that we use UpdateAddrs (I was also thinking about fixing SetAddrs) but I actually like this more.

Maybe we should downgrade these to TempAddrTTL instead of 0? Honestly, I'm fine either way and TempAddrTTL is long enough that that might cause problems. My only concern is that we'll have a short period where we'll have no good addresses.

We could also use a constant 10s timeout (for really temporary addresses).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a valid concern I think, so I'll update to use a 10s ttl to cover the gap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I called it transientTTL and it's 10s long; maybe we should have this constant in the peerstore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's what TempAddrTTL was supposed to be...

ids.Host.Peerstore().AddAddrs(p, lmaddrs, pstore.ConnectedAddrTTL)
default:
ids.Host.Peerstore().UpdateAddrs(p, pstore.ConnectedAddrTTL, 0)
ids.Host.Peerstore().AddAddrs(p, lmaddrs, pstore.RecentlyConnectedAddrTTL)
}
ids.addrMu.Unlock()
Expand Down