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

Add LastUsefulAt and LastSuccessfulQueryAt for each peer #75

Merged
merged 3 commits into from Apr 9, 2020

Conversation

aarshkshah1992
Copy link
Contributor

LastUsefulAt helps evict peers that aren't being useful.
LastSuccessfulQueryAt decides which peers we ping periodically to check liveliness.

table.go Outdated Show resolved Hide resolved
@@ -129,7 +128,8 @@ func (rt *RoutingTable) addPeer(p peer.ID, queryPeer bool) (bool, error) {

// We have enough space in the bucket (whether spawned or grouped).
if bucket.len() < rt.bucketsize {
bucket.pushFront(&PeerInfo{p, lastSuccessfulOutboundQuery, ConvertPeerID(p)})
bucket.pushFront(&PeerInfo{Id: p, LastUsefulAt: lastUsefulAt, LastSuccessfulOutboundQueryAt: time.Now(),
Copy link
Member

Choose a reason for hiding this comment

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

Technically LastSuccessfullOutboundQueryAt might be wrong (could be an inbound query)... but it's probably fine.

defer rt.tabLock.Unlock()

bucketID := rt.bucketIdForPeer(p)
bucket := rt.buckets[bucketID]
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a helper function for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Stebalien Good point. Will make sure I do in the next RT PR I create.

@Stebalien Stebalien merged commit 6f708c1 into master Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants