-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Remove p2pservice networkcodec trait #2388
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
Merged
Merged
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
b6f7353
Request/Response: remove NetworkCodec trait
acerone85 529d1d6
Dinstinguish between Format being used and Codec for requests and res…
acerone85 a4465d5
Move RequestResponse protocol definitions to dedicated module
acerone85 7b858c5
Decouple GossibSub and RequestResponse codecs
acerone85 f2cd720
Merge branch 'master' into 2368-remove-p2pservice-networkcodec-trait
acerone85 1aa98dc
Simplify DataFormat trait
acerone85 79b507d
Use Encode and Decode trait in favour of DataFormat
acerone85 ead761a
Rename codecs to message handlers
acerone85 ed29376
Format
acerone85 138716b
Encode trait function takes &self as argument
acerone85 58ffe67
Minor improvements
acerone85 c564941
Decode trait function takes &self as argument
acerone85 c5aa362
DataFormat is now Codec
acerone85 89b022c
Typo
acerone85 45bbd91
CHANGELOG
acerone85 caf4f00
Add issue to TODO
acerone85 a55f695
Rename lifetime
acerone85 fc2d71d
Formatting
acerone85 136e6b4
Placate Clippy
acerone85 5bd9e21
Merge branch 'master' into 2368-remove-p2pservice-networkcodec-trait
acerone85 029fbff
Fix test compilation
acerone85 39e1ed9
Merge branch 'master' into 2368-remove-p2pservice-networkcodec-trait
acerone85 05c50fd
Reference todo issue
acerone85 e9f1404
Avoid dereference
acerone85 b94c451
Todo: max_response_size should be u64
acerone85 fa021c5
Merge branch 'master' into 2368-remove-p2pservice-networkcodec-trait
acerone85 a9c9eca
Remove issue to move codec
acerone85 cbfd9a7
Remove spurious anyhow::Error
acerone85 d4e2198
se Vec<u8> for Encoder to avoid cloning
acerone85 d40b532
Remove Send trait bound
acerone85 5063dec
futures::AsyncWrite -> AsyncWrite
acerone85 07924f6
unboundedCodec -> PostcardCodec
acerone85 ad57a6b
Remove default implementation of ReqRes protocol
acerone85 8faebd1
as_vec -> to_vec
acerone85 061886d
Revert "se Vec<u8> for Encoder to avoid cloning"
acerone85 37e4e23
Do not clone into Vec<u8>
acerone85 be931ff
Update crates/services/p2p/src/codecs.rs
xgreenx b92e7e0
Merge branch 'refs/heads/master' into 2368-remove-p2pservice-networkc…
xgreenx b608036
Use new Changelog
xgreenx 1cbdfb4
Use new Changelog
xgreenx 4db8318
Merge branch 'master' into 2368-remove-p2pservice-networkcodec-trait
acerone85 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| use std::io; | ||
|
|
||
| use fuel_core_types::fuel_tx::Transaction; | ||
|
|
||
| use crate::gossipsub::messages::{ | ||
| GossipTopicTag, | ||
| GossipsubBroadcastRequest, | ||
| GossipsubMessage, | ||
| }; | ||
|
|
||
| use super::{ | ||
| Decode, | ||
| Encode, | ||
| Encoder, | ||
| GossipsubCodec, | ||
| }; | ||
|
|
||
| #[derive(Debug, Clone, Default)] | ||
| pub struct GossipsubMessageHandler<Codec> { | ||
| pub(crate) codec: Codec, | ||
| } | ||
|
|
||
| impl<Codec> GossipsubCodec for GossipsubMessageHandler<Codec> | ||
| where | ||
| Codec: | ||
| Encode<Transaction, Error = io::Error> + Decode<Transaction, Error = io::Error>, | ||
| { | ||
| type RequestMessage = GossipsubBroadcastRequest; | ||
| type ResponseMessage = GossipsubMessage; | ||
|
|
||
| fn encode(&self, data: Self::RequestMessage) -> Result<Vec<u8>, io::Error> { | ||
| match data { | ||
| GossipsubBroadcastRequest::NewTx(tx) => { | ||
| Ok(self.codec.encode(&tx)?.to_bytes()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn decode( | ||
| &self, | ||
| encoded_data: &[u8], | ||
| gossipsub_tag: GossipTopicTag, | ||
| ) -> Result<Self::ResponseMessage, io::Error> { | ||
| let decoded_response = match gossipsub_tag { | ||
| GossipTopicTag::NewTx => { | ||
| GossipsubMessage::NewTx(self.codec.decode(encoded_data)?) | ||
| } | ||
| }; | ||
|
|
||
| Ok(decoded_response) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.