refactor: large refactor of networking plus tests #2488
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.
Network Module Refactoring and Quality Improvements
Overview
This PR implements a major refactoring of the ant-networking library, focusing on improving code organization, type safety, error handling, and testing. The changes follow a structured approach to enhance maintainability and reliability while maintaining backward compatibility.
Key Changes
1. Driver Module Restructuring
driver.rs
into focused submodules:driver/mod.rs
: Main module definitiondriver/builder.rs
: Network builder pattern implementationdriver/swarm.rs
: Core swarm managementdriver/event_handler.rs
: Event processing logicdriver/storage.rs
: Record storage operationsdriver/peer_management.rs
: Peer connection handling2. Enhanced Type Safety
NetworkPrice
for safe price handlingNetworkDistance
for distance metricsNetworkTimeout
for duration management3. Improved Error Handling
4. Event System Optimization
5. Metrics and Logging
6. Testing Improvements
Implementation Details
Type System Improvements
Enhanced Error Handling
Event Processing
Testing Strategy
Migration Guide
No breaking changes introduced. Existing code should continue to work without modification.
Performance Impact
Documentation
Future Work
Testing Done
Checklist