-
Notifications
You must be signed in to change notification settings - Fork 875
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
fix(kad): correctly handle NoKnownPeers
error when bootstrap
#5349
base: master
Are you sure you want to change the base?
fix(kad): correctly handle NoKnownPeers
error when bootstrap
#5349
Conversation
This looks a bit hacky, wouldn't it be better to modify the bootstrap |
I'm not sure to understand what you mean. Even if I would update the I agree that it would feel better to have a passive way to learn that a bootstrap did start or finish but I don't see how to implement that in a reasonably simple manner. The reason we need to know if a bootstrap as started or finished is because we don't want to cascade bootstrap requests. When a bootstrap is triggered (no matter if it was automatic, periodic or manual), we reset the automatic and periodic timer to their initial value. |
7aba7ef
to
67e9aca
Compare
67e9aca
to
ec9898f
Compare
@@ -931,6 +931,7 @@ where | |||
/// This parameter is used to call [`Behaviour::bootstrap`] periodically and automatically | |||
/// to ensure a healthy routing table. | |||
pub fn bootstrap(&mut self) -> Result<QueryId, NoKnownPeers> { | |||
self.bootstrap_status.on_started(); |
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.
What I meant is that if peers.is_empty()
we may not want to call self.bootstrap_status.on_started()
at all, because we aren't performing a bootstrap.
If a periodic timer needs to be reset within the Status
then the timer reset should probably be implemented there rather than calling on_started()
, because no actual bootstrap is started. Or maybe I didn't understand what the original issue is?
Description
After testing
master
, we encountered a bug due to #4838 when doing automatic or periodic bootstrap if the node has no known peers.Since it failed immediately, I though there was no need to call the
bootstrap_status.on_started
method. But no doing so never reset the periodic timer insidebootstrap_status
resulting in getting stuck to try to bootstrap every timepoll
is called onkad::Behaviour
.Notes & open questions
N/A
Change checklist