Skip to content
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

Merged
merged 3 commits into from
Jun 24, 2022
Merged

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Jun 23, 2022

Implements AwaitAllConnected method for sync.Server.

category: feature
ticket: #684

@codecov
Copy link

codecov bot commented Jun 23, 2022

Codecov Report

Merging #743 (8c4bcff) into main (2bc98cb) will increase coverage by 0.17%.
The diff coverage is 69.04%.

@@            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     
Impacted Files Coverage Δ
dkg/sync/client.go 64.35% <30.76%> (-1.63%) ⬇️
dkg/sync/server.go 68.00% <86.20%> (+8.00%) ⬆️
core/qbft/qbft.go 80.47% <0.00%> (-1.51%) ⬇️
core/leadercast/transport.go 76.33% <0.00%> (+1.18%) ⬆️
core/dutydb/memory.go 75.59% <0.00%> (+1.78%) ⬆️
app/app.go 60.75% <0.00%> (+3.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bc98cb...8c4bcff. Read the comment docs.

@dB2510 dB2510 requested a review from xenowits June 23, 2022 13:43
func (*Server) AwaitAllConnected() error {
func (s *Server) AwaitAllConnected() error {
var msgs []result
for len(msgs) < len(s.peers) {
Copy link
Contributor

@xenowits xenowits Jun 23, 2022

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)
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm looks fair then

dkg/sync/server.go Outdated Show resolved Hide resolved
Co-authored-by: Abhishek Kumar <43061995+xenowits@users.noreply.github.com>
@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jun 24, 2022
@obol-bulldozer obol-bulldozer bot merged commit 40ba42d into main Jun 24, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/awaitall branch June 24, 2022 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants