-
Notifications
You must be signed in to change notification settings - Fork 144
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
set createTime per node and purge old nodes if maxNodes is reached #57
Changes from 1 commit
62d4599
e1c56f8
fe74c1f
450debb
f2a1acd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,12 @@ func (r *routingTable) cleanup(cleanupPeriod time.Duration, p *peerStore) (needP | |
r.kill(n, p) | ||
continue | ||
} | ||
// kill old and currently unused nodes if nodeCount is > maxNodes | ||
if len(r.addresses) > p.maxNodes && time.Since(n.createTime) > cleanupPeriod && len(n.pendingQueries) == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say we should kill the node even if there are pending queries. If it's so old, better refresh the routing table with newer models? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may have just sent out a query a second ago to that specific node, because of the nearest distance to the searched hash.. so we don't want to loose that result? |
||
log.V(4).Infof("DHT: Old node with 0 pendingQueries. Deleting") | ||
r.kill(n, p) | ||
continue | ||
} | ||
if n.reachable { | ||
if len(n.pendingQueries) == 0 { | ||
goto PING | ||
|
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.
Do we really need this? I don't think we do and I think it's better to only expose methods when we really need to. Besides, I think this isn't safe to be used concurrently while the DHT is running?
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.
agree. was just usefull for my debuging.