-
Notifications
You must be signed in to change notification settings - Fork 37
Improve error messages when remote addresses are bad #101
Conversation
02574c4
to
2da188f
Compare
2da188f
to
e1d4fbb
Compare
Fixes #69. |
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.
I do not think this PR brings any improvement, and in fact it adds a superfluous goroutine and makes the code less readable by substituting a digestible loop with a dance of boolean flags, counters and unnecessary synchronisation because the whole thing has no reason to be multithreaded.
The original intention was based on wrong assumptions, that we clarified during conversation.
The title is also misleading, as it suggests we're only improving an error code, but in reality it attempts to sneak in a refactor of the dialling loop.
@anacrolix I think we're better off closing this PR – I'll let you do it. Please submit the error message improvement separately.
This reverts commit c27f3f0.
e1d4fbb
to
63776e0
Compare
I've refactored this back to the channel model, with the optimistic select. I need the more specific error messages as "default failure" is getting really old really quick and making debugging a pain. |
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.
@anacrolix I don't like this mixture of functional and procedural (and the added indirection) just to shortcut 2-3 lines of code. To me, the value prop is not there, especially given that repetition in Go is idiomatic. I much rather read this linearly than seesawing up and down.
I suggest this PR sticks to introducing an exported error for when we have no remote addresses to dial. |
I'm on board with that error now, I'll add it. |
@raulk This error, if exposed, belongs in go-libp2p-net, as a part of the Dialer and Network interfaces there. |
It's explicit about identical behaviour on different sets of communication clauses in the select. I think it's worth doing, especially with the extensive behaviour and comments in |
This now requires libp2p/go-libp2p-net#38 to be merged. |
Isn't 90% of this PR a bike-shed of First, would you mind making this PR stick to its title? Second, you're proposing to introduce a personal stylistic preference on code that has been vetted by the community at large. As I explained above, IMO your change introduces extra bookkeeping variables, and makes it unreadable linearly. This is a critical part of the system where explicitness is appreciated. Optimistic selects are used largely in the codebase in their denormalised form. I also believe that, in Go, repetitiveness is OK and idiomatic. Moreover, the resulting block has no substantial reduction in LoC either, so by all accounts I really don't understand your insistence here. To move forward, I propose to stop beating a dead horse. Can you close this PR and open a new one, just with the changes announced in the title, which are pretty non-controversial? If you really want to push the closure stuff, open a separate PR just for that and try to get others to chime in; you already know where I stand ;-) |
Improves the error message when there are no addresses because they're all filtered out, or none are given. Also the dial logic is simplified. Timing, and pseudo-random channel operations make optimistic selects unworthwhile.