refactor!: Simplify request/response system with enum-based approach#7
Draft
evanlinjin wants to merge 2 commits intobitcoindevkit:masterfrom
Draft
refactor!: Simplify request/response system with enum-based approach#7evanlinjin wants to merge 2 commits intobitcoindevkit:masterfrom
evanlinjin wants to merge 2 commits intobitcoindevkit:masterfrom
Conversation
BREAKING CHANGE: Request/Response API completely redesigned - Replace macro-based system with simple Request/Response enums - Inline all request parameters directly in enum variants - Split HeaderResp into HeaderResp/HeaderWithProofResp - Split HeadersResp into HeadersResp/HeadersWithCheckpointResp - Add clean ClientError enum for all client methods - Fix blocking client tests to use proper synchronization
849ffd6 to
4ca0614
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Breaking Changes
This PR completely redesigns the request/response API to be simpler and more maintainable.
Summary
Replaces the complex macro-based request/response system with straightforward enums, improving code clarity and reducing complexity.
Changes
Request System
Requestenumpending_request.rsandbatch_request.rs(no longer needed)Response System
Responseenum for all response typesHeaderResp→HeaderResp(simple) andHeaderWithProofResp(with merkle proof)HeadersResp→HeadersResp(simple) andHeadersWithCheckpointResp(with checkpoint)from_json()based on fields presentError Handling
ClientErrorenum with just 3 variants:SendError,ServerError,CancelledClient API
AsyncClientandBlockingClientheader()returnsHeaderResp,header_with_proof()returnsHeaderWithProofResp)Testing
env.wait_until_electrum_sees_block()Motivation
The previous macro-based system was:
The new enum-based approach:
Migration Guide
Closes #6