refactor(ffi): DRY the accessor layer and the lock-discipline fixtures - #1233
Draft
zancas wants to merge 1 commit into
Draft
refactor(ffi): DRY the accessor layer and the lock-discipline fixtures#1233zancas wants to merge 1 commit into
zancas wants to merge 1 commit into
Conversation
Nearly every lightclient accessor call site repeated the same frame: a closure whose tail drives an async body with RT.block_on. Two AsyncFnOnce wrappers, with_initialized_lightclient_async and its read sibling, now own that frame, and the 40 call sites matching the shape write only their awaits. The five sites left on the plain accessors stay deliberately: poll_sync, pause_sync, and run_sync have sync or conditional bodies, and the drain, quick_split, and execute_due_parts sites arm a progress side channel where the block_on placement is load-bearing and documented. The lock-discipline tests likewise repeated a three-line preamble nineteen times. fixture() takes the serial guard and builds the offline wallet; fixture_answer() adds the held-read-guard call for the sixteen tests with nothing in between. The three composite tests keep the granular pieces behind one fixture() call. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Follow-up to #1230, one commit: the DRY pass over the accessor layer and the lock-discipline tests.
The crate is edition 2024, so AsyncFnOnce closures are available. Two wrappers,
with_initialized_lightclient_asyncandwith_initialized_lightclient_read_async, now own theRT.block_onframe that 40 call sites (write and read alike, including the endpoints dev already had) repeated around their async bodies. Each converted site writes only its awaits. Five sites stay on the plain accessors on purpose:poll_sync,pause_sync, andrun_synchave sync or conditional bodies, and the drain,quick_split, andexecute_due_partssites arm a progress side channel where the block_on placement is load-bearing and documented in place.On the test side,
fixture()(serial guard + offline wallet) andfixture_answer()(fixture + held-read-guard call) replace the three-line preamble the nineteen lock-discipline tests repeated. Sixteen tests fold to the combined helper; the three composite tests keep the granular pieces behind onefixture()call.cargo check --all-targetsclean,cargo nextest run -p zingo54/54. Net −80 lines. Based onread_lock_ports(#1230); retarget to dev when that merges.🤖 Generated with Claude Code