eth::ChainTracker¶
Tracks the chain tip and deduplicates block processing requests. More...
#include <chain_tracker.hpp>
Public Functions¶
| Name | |
|---|---|
| ChainTracker(size_t window_size =kDefaultWindowSize) Construct with an optional custom deduplication window size. |
|
| ~ChainTracker() =default | |
| ChainTracker(const ChainTracker & ) =delete | |
| ChainTracker & | operator=(const ChainTracker & ) =delete |
| ChainTracker(ChainTracker && ) =default | |
| ChainTracker & | operator=(ChainTracker && ) =default |
| bool | mark_seen(const codec::Hash256 & block_hash, uint64_t block_number) Attempt to mark a block as "receipts requested". |
| bool | is_seen(const codec::Hash256 & block_hash) const Return true if this block hash has already been seen. |
| uint64_t | tip() const Return the highest block number seen so far (0 if none). |
| std::optional< codec::Hash256 > | tip_hash() const Return the hash of the highest block seen, if any. |
| size_t | seen_count() const Return the number of blocks currently in the deduplication window. |
| void | reset() Reset all state (tip, seen set, eviction queue). |
Public Attributes¶
| Name | |
|---|---|
| size_t | kDefaultWindowSize Maximum number of block hashes to remember for deduplication. Older entries beyond this window are evicted (FIFO order by insertion, not by block number). |
Detailed Description¶
Tracks the chain tip and deduplicates block processing requests.
Responsibilities:
- Record which blocks have already had their receipts requested so duplicate GetReceipts messages are never emitted for the same block.
- Track the highest known block number (the "tip").
- Detect when a block arrives that is lower than the current tip (potential reorg or redundant announcement).
This class is intentionally minimal — it does not store headers or receipts; it only tracks identity (hash) and height (number).
Thread-safety: not thread-safe. All calls must be externally synchronized.
Public Functions Documentation¶
function ChainTracker¶
Construct with an optional custom deduplication window size.
function ~ChainTracker¶
function ChainTracker¶
function operator=¶
function ChainTracker¶
function operator=¶
function mark_seen¶
Attempt to mark a block as "receipts requested".
Parameters:
- block_hash Hash of the block being processed.
- block_number Height of the block.
Return: true if this is the first time this block has been seen.
If this block hash has already been seen, returns false and the caller should NOT emit another GetReceipts request. If it is new, records it and returns true — the caller should proceed.
Also updates the tip if block_number > current tip.
function is_seen¶
Return true if this block hash has already been seen.
function tip¶
Return the highest block number seen so far (0 if none).
function tip_hash¶
Return the hash of the highest block seen, if any.
function seen_count¶
Return the number of blocks currently in the deduplication window.
function reset¶
Reset all state (tip, seen set, eviction queue).
Public Attributes Documentation¶
variable kDefaultWindowSize¶
Maximum number of block hashes to remember for deduplication. Older entries beyond this window are evicted (FIFO order by insertion, not by block number).
Updated on 2026-04-13 at 23:22:46 -0700