Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add chain tracker to track chain head (#77)
### TL;DR Implemented a ChainTracker to monitor and report the latest block number in the current chain. ### What changed? - Added a new `ChainHead` metric in `metrics.go` to track the latest block number. - Created a new `chain_tracker.go` file with a `ChainTracker` struct and associated methods. - The `ChainTracker` polls the RPC at regular intervals to fetch the latest block number. - Updated the `Orchestrator` to start the `ChainTracker` alongside other components. ### How to test? 1. Run the indexer with the new changes. 2. Monitor the `chain_tracker_chain_head` metric using Prometheus or a similar monitoring tool. 3. Verify that the metric is updating at regular intervals (default: every 5 minutes). 4. Compare the reported chain head with the actual latest block number on the blockchain to ensure accuracy. ### Why make this change? This change allows for real-time tracking of the blockchain's progress, providing valuable information about the current state of the chain. This can be useful for: 1. Monitoring the health of the blockchain network. 2. Detecting potential network issues or delays. 3. Providing context for other indexer operations and metrics. 4. Enabling more accurate synchronization and data consistency checks.
- Loading branch information