Reduxed with channel semaphore - #44
Conversation
Proposed changes include: * Using a buffered channel. * Using a groupSemaphre to wait for goroutines to finish. * Closing the membersChannel when we're done with it (have members list populated). * Eliminating the loop that counts seenMembers.
|
No reason to include code differences in the PR description- we can see it in the diff |
|
Hey @l3x Using a buffered channel and closing the members channel are great ideas/ nice optimizations. Specifically regarding This would help you remove a few things, specifically: thereby truly satisfying Also, another fun trick, rather than using Side note, from the As for merging this in/final thoughts, I'll leave it to @Shadowfiend |
|
I agree! Using that pattern is better... ... It can be used in more scenarios. Howevever, with the one memberChannel I'm not sure there'd be a chance for race condition using my old-school semaphore method? Either way, I think we have a win! Formatting suggestionDoes this look more compact and readable... ... than this? p.s. Thanks for the |
|
Nice discussion y'all, learned a bit more about available primitives and such! A few more “process-y” notes on this PR (for all participants):
Again, good discussion; we'll narrow in on improving our process practices so no worries. With all of that said, if we'd made these requests on the original PR, I would probably have declined to implement them (as I did when Raghav mentioned something similar in the original Guard Tower PR) because I expect this main function to be lit on fire within 2 weeks at most 😞 It's quick, it's dirty, and it's short-lived; unless it's actually broken (which I don't think it is?), it's not really worth spending much time with it. If you've got concerns about the existing stuff actually being broken, please share them on the original PR; for now, I'll close this one.
More compact, less readable, IMO. It's easier to have a solid rule on how to break things into lines (multiple lines = one arg per line) than it is to vary it (multiple lines = however many args per line the current line width admits; this makes determining all of a function's arguments at a glance more complicated). As a general rule, I prefer readability/skimmability to compactness. Making code review a core part of our process also emphasizes this preference, since you are guaranteed to have at least one person trying to read through your code who isn't you. |
|
I wanted to expand a touch on some of the implications of the “let the author work on their own PR” principle… I thought about it some more yesterday and this morning and realized I provided some poor advice yesterday. My key conclusion I want to get at: opening a PR against an open PR is almost never the best thing to do. Of course… I totally suggested it as a solution yesterday, so what gives? In general, opening a PR against an open PR should be a last resort. To start, comments in a PR should rarely be code, they should be English requests + reasoning for why those requests are a good idea. They might feature a code fragment or two to clarify what you mean, but their primary purpose is communicating gaps/problems and why you think they are gaps/problems. The author of the PR is assumed to be a good developer; if they have clarification questions, they'll ask them, and if they have trouble implementing your English requests in code, they should ask as well. Now, if you go back and forth a few times in a PR, but you feel like you're not getting anywhere, then and only then it can be helpful to fire up a branch so you can show, in code, what you mean. At this point, it still may not make sense to open a PR. You can link directly to the commit you made on your branch from the author's PR, from an existing comment thread, and say “this is more what I had in mind”. Your code in this case isn't meant for inclusion, but for education.[1] This circles back to the idea that code review is a learning opportunity for the author. If, as a reviewer, you spot an issue and call it out, you've spotted something the author didn't. That means there's a teaching opportunity for the reviewer, and a learning opportunity for the author. Implementing the change for the author (a) requires you to flip into their work (inefficient for you) and (b) reduces their opportunity to fully investigate and interact with the suggestion you're making. Asking a question in a line or PR comment ("Should we…?”) and justifying it ("so that…") has a few implications:
Now, as usual, these aren't ironclad rules. There are times when it makes sense to drop a suggestion, and you don't fully know why you prefer it. In general, though, I expect this to be rare; really, I'd consider it a case of “don't break the rules until you know them”: don't let yourself make a suggestion unless you can explain it for a while. If someone makes a suggestion but doesn't explain it, ask them to justify. It helps us all understand each other a little bit better, too! [1] This ignores the possibility of having a pair programming call where you explain your thoughts/show what you mean. Just don't forget to summarize the conclusions of that call in a comment or commit message. The author can commit the final changes and include the reasoning that was reached, for example. Or, if the conclusion is that the change isn't quite right, the reason for that can be posted on the comment thread. |
Change Rospten testnet for Goerli
Proposed changes include:
main.go
FROM
TO