refactor(blockchain): extract sync status tracker#436
Conversation
Greptile SummaryThis PR extracts the sync-status heuristic from
Confidence Score: 5/5Safe to merge — this is a pure code-organisation change with no behavioural differences. Every moved item (struct, constants, method body, tests) is byte-for-byte identical to what was in lib.rs. Module visibility is correctly narrowed to pub(crate), the new module is private to the crate, and all six existing tests continue to cover the same logic paths as before. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/sync_status.rs | New module containing the extracted SyncStatusTracker, its three constants, update logic, and all six tests — identical to what was removed from lib.rs. |
| crates/blockchain/src/lib.rs | Removes the inline SyncStatusTracker definition and its tests; adds mod sync_status and the corresponding use import. No other logic changed. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[BlockChainServer] -->|calls| B[SyncStatusTracker::update]
B --> C{network_lag > NETWORK_STALL_THRESHOLD?}
C -->|Yes| D[syncing = false\nSyncStatus::Synced]
C -->|No| E{currently syncing?}
E -->|Yes - hysteresis| F{head_lag > THRESHOLD - BAND?}
E -->|No| G{head_lag > THRESHOLD?}
F -->|Yes| H[syncing = true\nSyncStatus::Syncing]
F -->|No| I[syncing = false\nSyncStatus::Synced]
G -->|Yes| H
G -->|No| I
subgraph sync_status.rs
B
C
D
E
F
G
H
I
end
Reviews (1): Last reviewed commit: "Merge branch 'main' into refactor/extrac..." | Re-trigger Greptile
🗒️ Description / Motivation
crates/blockchain/src/lib.rs.What Changed
crates/blockchain/src/sync_status.rs.SyncStatusTrackerinto the new module.lib.rsto import and use the extracted tracker.Correctness / Behavior Guarantees
pub(crate).Tests Added / Run
cargo fmt --all— clean.cargo test -p ethlambda-blockchain --lib sync_status --locked— 6 passed.cargo clippy -p ethlambda-blockchain --all-targets --locked -- -D warnings— clean.git diff --check— clean.Related Issues / PRs
✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleancargo test --workspace --release— all passing