Skip to content

network: add OutgoingMessage disconnectReason field#5147

Merged
algorandskiy merged 2 commits into
algorand:masterfrom
cce:OutgoingMessage-disconnectReason
Feb 21, 2023
Merged

network: add OutgoingMessage disconnectReason field#5147
algorandskiy merged 2 commits into
algorand:masterfrom
cce:OutgoingMessage-disconnectReason

Conversation

@cce
Copy link
Copy Markdown
Contributor

@cce cce commented Feb 17, 2023

Summary

Following up on feedback from #4695, this adds an unexported disconnectReason field to the OutgoingMessage field for use with tracking internal network handlers' reasons for disconnecting.

Test Plan

Extended TestWebsocketDisconnection to use this new feature and assert the correct reason was reported.

@cce cce requested a review from AlgoAxel February 17, 2023 21:53
algorandskiy
algorandskiy previously approved these changes Feb 17, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 17, 2023

Codecov Report

Merging #5147 (a2503f6) into master (b84f980) will decrease coverage by 0.03%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##           master    #5147      +/-   ##
==========================================
- Coverage   53.56%   53.54%   -0.03%     
==========================================
  Files         433      433              
  Lines       54736    54736              
==========================================
- Hits        29321    29310      -11     
- Misses      23136    23141       +5     
- Partials     2279     2285       +6     
Impacted Files Coverage Δ
network/wsNetwork.go 69.14% <80.00%> (+0.33%) ⬆️
network/netidentity.go 100.00% <100.00%> (ø)
ledger/tracker.go 72.91% <0.00%> (-1.67%) ⬇️
ledger/catchpointtracker.go 55.89% <0.00%> (-1.54%) ⬇️
catchup/service.go 69.64% <0.00%> (-0.71%) ⬇️
ledger/acctonline.go 76.90% <0.00%> (-0.51%) ⬇️
network/wsPeer.go 71.26% <0.00%> (ø)
ledger/testing/randomAccounts.go 56.26% <0.00%> (+0.61%) ⬆️
agreement/proposalManager.go 98.03% <0.00%> (+1.96%) ⬆️
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cce cce force-pushed the OutgoingMessage-disconnectReason branch from ebd951b to a2503f6 Compare February 18, 2023 21:33
Comment thread network/wsNetwork.go
Comment on lines -312 to +313
return OutgoingMessage{Broadcast, msg.Tag, msg.Data, nil}
return OutgoingMessage{Action: Broadcast, Tag: msg.Tag, Payload: msg.Data, Topics: nil}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

was this a required change? just wondering because I don't see a difference besides adding the attribute names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, adding an extra field made struct initializations not work here because all the fields have to be specified if you aren't providing the field names.

Comment thread network/wsNetwork.go
Comment on lines +1290 to +1294
reason := disconnectBadData
if outmsg.reason != disconnectReasonNone {
reason = outmsg.reason
}
go wn.disconnectThread(msg.Sender, reason)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clever! I was thinking about the work required to include the badData to all disconnect messages, but this is way cleaner.

Copy link
Copy Markdown
Contributor Author

@cce cce Feb 21, 2023

Choose a reason for hiding this comment

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

yes, it is the current default and is already being set in this line, so I kept it set as default here in the line I replaced it with

@algorandskiy algorandskiy merged commit 0701543 into algorand:master Feb 21, 2023
@cce cce deleted the OutgoingMessage-disconnectReason branch March 1, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants