Commit 23884ad
authored
track latest block immediately on start (#216)
### 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?
- Extracted the block number tracking logic into a new `trackLatestBlockNumber` method
- Added a call to `trackLatestBlockNumber` immediately after the ChainTracker starts, before entering the main loop
- Updated the ticker handler to call the new method instead of containing the logic directly
### How to test?
1. Start the application and verify that the chain tracker begins tracking the latest block number immediately
2. Check logs to confirm the tracker continues to update at regular intervals
3. Verify that metrics for ChainHead are being set correctly
### Why make this change?
This change improves the ChainTracker by:
1. Tracking the latest block number immediately on startup instead of waiting for the first ticker event
2. Improving code organization by extracting the tracking logic into a reusable method
3. Reducing code duplication between the initial tracking and the periodic updates
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **Refactor**
- Improved internal logic for tracking and updating the latest block number, resulting in more modular and maintainable code. No changes to user-facing functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 file changed
+13
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 40 | + | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments