Fix: Initialize _last_block_timestamp from head block on startup
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 5s
Integration Tests / test-service-integration (push) Failing after 10s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 4s
P2P Network Verification / p2p-verification (push) Successful in 4s
Python Tests / test-python (push) Successful in 12s
Security Scanning / security-scan (push) Successful in 30s

This fixes the hybrid mode heartbeat logic which was unable to
calculate time since last block after service restart because
_last_block_timestamp was None.
This commit is contained in:
aitbc
2026-04-23 11:02:03 +02:00
parent 4b001a95d2
commit 6a7258941a

View File

@@ -114,6 +114,13 @@ class PoAProposer:
return
self._logger.info("Starting PoA proposer loop", extra={"interval": self._config.interval_seconds})
await self._ensure_genesis_block()
# Initialize last block timestamp from head block for heartbeat logic
head = self._fetch_chain_head()
if head is not None:
self._last_block_timestamp = head.timestamp
self._logger.info("Initialized last block timestamp from head", extra={"height": head.height})
self._stop_event.clear()
self._task = asyncio.create_task(self._run_loop())