-
Notifications
You must be signed in to change notification settings - Fork 19
track latest block immediately on start #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
""" WalkthroughThe update refactors the logic for fetching and updating the latest block number in the Changes
Sequence Diagram(s)sequenceDiagram
participant StartMethod as ChainTracker.Start
participant Tracker as ChainTracker
participant RPC as RPC Client
participant Metrics as Metrics
StartMethod->>Tracker: trackLatestBlockNumber(ctx)
Tracker->>RPC: Get latest block number
alt Success
RPC-->>Tracker: Block number
Tracker->>Metrics: Update ChainHead metric
else Error
Tracker->>Tracker: Log error
end
loop On each ticker event
StartMethod->>Tracker: trackLatestBlockNumber(ctx)
Tracker->>RPC: Get latest block number
alt Success
RPC-->>Tracker: Block number
Tracker->>Metrics: Update ChainHead metric
else Error
Tracker->>Tracker: Log error
end
end
""" 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/orchestrator/chain_tracker.go (1)
32-32
: Test initial block tracking invocation
The new immediate callct.trackLatestBlockNumber(ctx)
ensures the latest block is fetched right afterStart()
. Consider adding a unit or integration test mockingrpc.IRPCClient
to assert thatGetLatestBlockNumber
is invoked before the first ticker tick.Can provide a sample test if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/orchestrator/chain_tracker.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/orchestrator/chain_tracker.go (1)
internal/metrics/metrics.go (1)
ChainHead
(44-47)
🔇 Additional comments (1)
internal/orchestrator/chain_tracker.go (1)
39-41
: Reuse tracking logic in ticker loop
Refactoring the ticker case to calltrackLatestBlockNumber()
instead of inlining the fetch/update logic reduces duplication and improves readability. Nice work!
18cd55e
to
ab704ec
Compare
TL;DR
Refactored the ChainTracker to track the latest block number immediately on start and extract the tracking logic into a separate method.
What changed?
trackLatestBlockNumber
methodtrackLatestBlockNumber
immediately after the ChainTracker starts, before entering the main loopHow to test?
Why make this change?
This change improves the ChainTracker by:
Summary by CodeRabbit