You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sync): collapse SyncState to enum plus single non-trivial property (leanEthereum#729)
SyncState was 163 lines for a 3-state enum. Most of the surface was
trivial `state == SyncState.X` wrappers and a state-machine helper
whose only caller was sync service. Net change: -225 lines across
4 files, zero behavior change.
Changes:
- states.py drops `is_idle`, `is_syncing`, `is_synced` properties
(trivial == wrappers), `can_transition_to` (one caller), and the
module-level `_VALID_TRANSITIONS` table. Keeps the enum and
`accepts_gossip`, the only property doing real work.
- service.py drops `SyncService.is_syncing` and `is_synced` public
wrappers (zero external callers). Replaces three call sites that
used the removed enum properties with direct comparisons.
- service.py rewrites `_transition_to` to inline the validity check.
The original 5-edge transition table becomes two invariants:
no self-transitions, no IDLE -> SYNCED shortcut. Same semantics
verified case-by-case against the original table.
- test_states.py shrinks to cover the surviving surface (enum
identity and accepts_gossip). The `_transition_to` invariants
now have coverage in test_service.py, including a new
self-transition test to replace the parametrized test that lived
on `can_transition_to`.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments