-
Notifications
You must be signed in to change notification settings - Fork 232
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
Run fixLowPeers on startup #694
Run fixLowPeers on startup #694
Conversation
@samsondav this is exposing a fairly internal function that is subject to change. What are you hoping to use it for? Are you just trying to make sure that it's called at startup, if so there are some other options available to us including:
|
We need it to run on startup, since we immediately query the DHT after instantiating it and we get "no peers found" error even though we provided bootstrap nodes. |
What do you think the best way to solve this problem is? |
I'm not sure offhand which of these three options is the best, although I suspect that having it always run on startup makes the most sense. @petar sound like a plan? |
I would have chosen adding as part of Bootstrap. So that at API level there is a clear contract that routing operations work after invoking a Bootsrap. |
@petar @aschmahmann I added it to Bootstrap, what do you think? |
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.
Seems good, just a couple comments to change and we're good to go. Thanks for the PR 😄
@petar commented this: FixLowPeers should be called and finish strictly before RefreshManager starts. We can hook this up. (pasted from slack convo) |
1577b8e
to
099c43e
Compare
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.
fixLowPeers must be syncronized with refresh manager trigger
@petar @aschmahmann I've updated it based on your most recent comments, would you mind taking another look? |
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.
Thanks for doing this and apologies for the delayed review. Left a couple small change requests and a question.
if err := dht.rtRefreshManager.Start(); err != nil { | ||
logger.Error(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.
Let's not put this in a separate goprocess and leave it in the init function, it's nice to return the errors on init since if we fail to start the refresh manager the DHT is dead. A log error, isn't nearly as good.
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 contrary to what @petar said above:
FixLowPeers should be called and finish strictly before RefreshManager starts
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.
Ah fair enough, for now this may to reduce start up errors from refreshing the routing table while it's still empty.
However, calling host.Connect()
on a bootstrap peer will not actually add the peer to the routing table immediately as that's triggered by a separate event. If we want to reduce those errors we'll have to add something that actually waits on peers initially being added to the routing table.
The git diff makes this look more invasive than it really is.
All I did was pull some logic out of fixLowPeersRoutine into a separate function and make it public. None of the functionality has been changed.