Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[P2P] refactor: message handling #763
[P2P] refactor: message handling #763
Changes from all commits
0c06d66
92ea049
593156c
2342035
3536afd
b942fed
a87e5cd
7f29e2b
dbd4965
47af1f2
ef21e79
77d91f1
1d0e1bf
33b5b58
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Here's a brief review of the code patch:
RainTreeConfig
andBackgroundConfig
structs are updated to include a new field,Handler
.rainTreeRouter
have been refactored.rainTreeRouter#HandleNetworkData()
andp2pModule#handleNetworkData()
are renamed to#handleRainTreeMsg()
and#handlePocketEnvelope()
, respectively, for better consistency.-tags=test
to all test make targets.mockdns
was fixed in theTestP2PModule_Insecure_Error
test.Overall, the changes seem reasonably-safe and no significant risks or bugs stand out. One possible improvement suggestion is to ensure that unit tests are updated accordingly to reflect method name changes such as
#handleRainTreeMsg()
and#handlePocketEnvelope()
. Additionally, it may be helpful to review the impact of refactored logging methods on overall system performance or log readability.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.
Should we add a linter for this? Dima recently added a custom one in
build/linters/tests.go
and it looks like we have access to theFile.Name
via the dsl matcher, but I don't know if there's any easy way to check for the first line.Can be done in a separate commit, not a blocker.
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.
It's only necessary to add the test build tag to:
Are you suggesting a linter which enforces the
test
build tag on all test files or something?I don't suppose there would really be a prohibitive downside to adding the test tag in places where it's not strictly necessary. I can imagine an argument for either but am leaning towards "ubiquitous build tags" at the moment (unexpectedly):
-tags test
; necessary in either case)go test
runs no testsgo test
runs some but not all testsThere 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.
The code patch provided seems reasonable, but I have a few minor suggestions for improvement. Please consider the following:
In line 19, add a comment to explain the purpose of moving the import statement and why it has been separated from the other import statements.
Although not incorrect, you might want to change lines 272-276 to avoid using the pointer to 'mod'. Instead, directly use 'p2pMod'. This increases readability and reduces complexity:
Make sure that there are unit tests (or create new unit tests) that cover the changes introduced in this patch. The current tests should pass, and any new edge cases should also be considered when testing.
Ensure that you follow the rest of the project's style and coding conventions when contributing your patch.
Overall, the code patch is generally fine, but addressing these points would lead to better quality code review.
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.
Why did you go with
Debug
instead ofError
here?Ditto below
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.
(see below)
In this case, my thinking was that this error only happens in the context of this logging helper function which is not a critical function. I didn't imagine that this logging helper producing an error would be useful to the end user (i.e. not actionable nor a useful signal). Perhaps I assume too much.