Return an error if we can't connect and limit the number of retries#813
Conversation
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
ZmnSCPxj
left a comment
There was a problem hiding this comment.
Mostly minor nits, this seems good.
| /* How many times have we attempted to connect? */ | ||
| u32 attempts; | ||
|
|
||
| /* How many timest to attempt */ |
There was a problem hiding this comment.
Nit: comment misspelling "timest"
| gossip_peer_already_connected,,id,struct pubkey | ||
|
|
||
| # gossipd -> master: attempted to connect, unsuccessful, gave up | ||
| gossip_peer_connection_failed,3020 |
There was a problem hiding this comment.
We need some good way to allocate message numbers, now I need to bump the message number in #638 again...
There was a problem hiding this comment.
Yes, fortunately compile will fail with a clash, so whoever is applying it can rebase and fixup...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell
left a comment
There was a problem hiding this comment.
Great work! Appended minor typo fixes for expedience...
| gossip_peer_already_connected,,id,struct pubkey | ||
|
|
||
| # gossipd -> master: attempted to connect, unsuccessful, gave up | ||
| gossip_peer_connection_failed,3020 |
There was a problem hiding this comment.
Yes, fortunately compile will fail with a clash, so whoever is applying it can rebase and fixup...
| u32 max_attempts; | ||
|
|
||
| /* Timestamp of the first attempt */ | ||
| u32 first_attempt; |
There was a problem hiding this comment.
Mildly prefer timestamps as struct timeabs, which is clearer, but not worth another round of feedback for.
| { | ||
| struct pubkey id; | ||
| u32 attempts, timediff; | ||
| struct connect *i, *next; |
| i->cmd, | ||
| "Could not connect to %s after %d seconds and %d attempts", | ||
| type_to_string(msg, struct pubkey, &id), timediff, | ||
| attempts); |
There was a problem hiding this comment.
We should probably standardize on indentation style for multiline calls sometime :)
| } | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
This seems like a lot of vertical space :)
Retrying to connect in eternity seems a bit unintuitive, so we limit to 10 attempts and keep track of when we started connecting. We could pass these parameters from
lightningdin the future, but this is the simplest solution for now. Also this fixes the hanging when we do not know an address and don't provide a hint.Fixes #681
Fixes #405
Fixes #390