-
Notifications
You must be signed in to change notification settings - Fork 988
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
protocols/gossipsub: Make use of prost-codec
#3070
Merged
mergify
merged 21 commits into
libp2p:master
from
nloadholtes:nloadholtes/2500-gossipsub-2
Nov 4, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0234417
Attempting to graft the prost_codec::Codec into the existing Gossipsu…
nloadholtes 51753e3
WIP
nloadholtes 329a27f
Replacing Error handling with the thiserror crate to be consistent
nloadholtes 4384869
Putting the codec into the constructor
nloadholtes cd85353
Fixes for encode, keeping GossipsubCode API untouched
nloadholtes d73a876
Setting codec length the max_length
nloadholtes 7eef2c8
Tests passing, cleanup: remove dead code and unused field. Replace de…
nloadholtes 0013e59
For consistency with Enocde, return a GossipsubHandlerError
nloadholtes e9370fb
CHANGELOG and Cargo version updates
nloadholtes 4253faa
version bumped
nloadholtes 59c5ac1
Error handling change
nloadholtes e37f4bf
Undoing formatting, adding link to PR
nloadholtes 9ba3551
Simplification of error handling, letting it bubble up
nloadholtes f656b7f
Simplification, changing back to allow decode to return Ok(None) in t…
nloadholtes c597afb
Map error like before
nloadholtes e38689a
Update CHANGELOG.md
nloadholtes 165b364
Simplify the match
nloadholtes d71ed19
Update protocols/gossipsub/CHANGELOG.md
thomaseizinger 98e3bef
Auto-generate `From` implementation
thomaseizinger 27984d2
Replace `use` alias with FQN
thomaseizinger 7edfe8f
Merge branch 'master' into nloadholtes/2500-gossipsub-2
jxs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Style question: in Python we do that fairly often to disambiguate names. In rust the fully qualified name is preferred? (Just want to make sure my thinking is on the right track)
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 is more a style-preference. I prefer full-qualified names because:
prost_codec
in this repository. If I come across a reference toprost_codec::Error
anywhere in the source-code, my brain just goes "Ah yeah, that must be the1 error type of that crate".Error
type, I can pretty much assume that it is the onlyError
type, otherwise the author would have named them differently (likeEncodeError
andDecodeError
for example).That is a lot of useful information to extract from a single line of code :)
On the contrary, if types are renamed on import:
ProstCodecError
, go the theuse
statements and check, what it actually is.In the end, it is about efficiency in being able to understand code. Especially the last point can be quite annoying :)
When you are hunting a bug f.e. your brain is usually in "spot odd things"-mode and an unfamiliar name is "odd" but in the case of renaming types, it is usually a false-positive.
It is a style thing at the end of the day so YMMV :)
Footnotes
Many crates by convention just have one error type. ↩