-
Notifications
You must be signed in to change notification settings - Fork 90
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
dkg/sync: add AwaitAllConnected for server #743
Conversation
Codecov Report
@@ Coverage Diff @@
## main #743 +/- ##
==========================================
+ Coverage 54.41% 54.58% +0.17%
==========================================
Files 107 107
Lines 10408 10432 +24
==========================================
+ Hits 5663 5694 +31
+ Misses 3921 3916 -5
+ Partials 824 822 -2
Continue to review full report at Codecov.
|
func (*Server) AwaitAllConnected() error { | ||
func (s *Server) AwaitAllConnected() error { | ||
var msgs []result | ||
for len(msgs) < len(s.peers) { |
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.
not a good practice imo to use value changing variables as loop vars. can do this instead:
for {
if len(msgs) >= len(s.peers) { break }
select {
case <-s.ctx.Done():
return s.ctx.Err()
case msg := <-s.receiveChan:
msgs = append(msgs, msg)
}
}
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.
Inspired from here: https://github.com/ObolNetwork/charon/blob/main/dkg/frostp2p.go#L178
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.
hmm looks fair then
Co-authored-by: Abhishek Kumar <[email protected]>
Implements AwaitAllConnected method for sync.Server.
category: feature
ticket: #684