-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add serde to peer_id #10
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
Conversation
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.
Pull Request Overview
This pull request introduces serde support for peer ID serialization and deserialization by implementing Serialize and Deserialize for FixedSizePeerID, along with corresponding tests and updates in related modules.
- Added a new serde module for peer ID encoding/decoding.
- Renamed PeerID to FixedSizePeerID in several locations to align naming conventions.
- Updated error handling and tests to use the new Error enum instead of ParsePeerIDError.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
sf-peer-id/src/serde.rs | Added serde implementations and tests for FixedSizePeerID. |
sf-peer-id/src/peer_id.rs | Updated FixedSizePeerID implementation and I/O functions for serde. |
sf-peer-id/src/lib.rs | Exposed new serde module and updated public API exports. |
sf-peer-id/src/hex.rs | Updated error type used in hex conversion functions. |
sf-peer-id/src/error.rs | Reworked error handling by replacing ParsePeerIDError with Error. |
sf-peer-id/Cargo.toml | Added serde and unsigned-varint dependencies with updated features. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10 +/- ##
==========================================
- Coverage 97.64% 97.63% -0.02%
==========================================
Files 19 20 +1
Lines 1572 1688 +116
Branches 28 32 +4
==========================================
+ Hits 1535 1648 +113
Misses 20 20
- Partials 17 20 +3
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
1e08f72
to
6927790
Compare
Signed-off-by: Sacha Froment <[email protected]>
Signed-off-by: Sacha Froment <[email protected]>
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.
Pull Request Overview
This PR adds serde support for peer identifiers by introducing serialization and deserialization for FixedSizePeerID and refactoring the associated error handling and naming. Key changes include:
- Adding a new serde module with implementations for serialization, deserialization, and a custom Visitor.
- Renaming the primary identifier type from PeerID to FixedSizePeerID with updated methods and error types.
- Updating tests, Cargo.toml dependencies, and related modules to support the new naming and error handling.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
sf-peer-id/src/serde.rs | Adds serde serialization/deserialization support using a dedicated buffer. |
sf-peer-id/src/peer_id.rs | Renames PeerID to FixedSizePeerID and updates methods (from_bytes, write, etc.) with new error handling. |
sf-peer-id/src/lib.rs | Updates re-exports to include the new Error type and FixedSizePeerID. |
sf-peer-id/src/hex.rs | Switches from ParsePeerIDError to the new Error type for hex conversion. |
sf-peer-id/src/error.rs | Refactors error handling with an expanded Error enum and related conversions. |
sf-peer-id/Cargo.toml | Adds serde and unsigned-varint dependencies and updates feature flags. |
sf-metrics/src/inmemory/implementation.rs | Updates format strings to use new interpolation syntax for metrics output. |
sf-metrics/src/inmemory/common.rs | Adjusts debug output formatting using new syntax. |
Comments suppressed due to low confidence (1)
sf-peer-id/src/peer_id.rs:17
- [nitpick] The struct is now named 'FixedSizePeerID' but some documentation comments and debug messages still refer to 'PeerID'. Consider updating these comments and outputs for consistency.
pub struct FixedSizePeerID<const S: usize> {
eb3448e
to
a4dd563
Compare
Signed-off-by: Sacha Froment <[email protected]>
Signed-off-by: Sacha Froment <[email protected]>
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.
Pull Request Overview
This PR introduces serde support for peer IDs and updates various code paths to use the new formatting capture syntax. Key changes include:
- Updating panic, log, and debug messages to use the new "{variable}" interpolation.
- Adding serde implementations and corresponding tests for FixedSizePeerID.
- Refactoring error handling to use a unified Error enum.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sf-server/src/ws.rs | Updated panic messages to use new formatting capture syntax. |
sf-server/src/state.rs | Updated logging messages for readability and consistency. |
sf-peer-id/src/serde.rs | Added serde (de)serialization support for FixedSizePeerID. |
sf-peer-id/src/peer_id.rs | Renamed PeerID to FixedSizePeerID and updated tests accordingly. |
sf-peer-id/src/hex.rs | Updated error returns to use the unified Error enum. |
sf-peer-id/src/error.rs | Refactored error handling with expanded Error variants. |
sf-peer-id/Cargo.toml | Enabled serde and updated dependency versions. |
sf-metrics/* | Updated string interpolation in metric formatting and tests. |
Comments suppressed due to low confidence (2)
sf-peer-id/src/peer_id.rs:347
- [nitpick] The test named 'test_peer_id_from_bytes_invalid_length' now uses from_str instead of from_bytes; consider renaming it to better reflect that it validates hex string input.
let result = FixedSizePeerID::<3>::from_str("deadbeef");
sf-server/src/ws.rs:171
- Ensure that the project's Rust compiler version supports the new formatting capture syntax (e.g., using {e} instead of the traditional "{}" pattern) to avoid potential runtime issues.
panic!("Failed to connect to WS after multiple attempts: {e}");
Signed-off-by: Sacha Froment [email protected]