Is your feature request related to a problem? Please describe.
- The
IForwardHeaderProvider.GetBlockHeaders returns the currently pending canonical chain that block downloader should download and process.
- This method is called on every peer allocation repeatedly.
- For
PowHeaderProvider, which download header directly from best peer, this call is cached, because a p2p call is just straight up too slow.
- For
PosHeaderProvider, this was not done for simplicity, preferring to call ChainLevelHelper which re-fetch header.
- This is the reason why there is a hard limit to header lookup in BlockDownloader
BlockDownloader.MaxHeaderLookup which limits the parallelism of block downloader. Which, is not nice, but at least much better than downloading from just a single peer.
Describe the solution you'd like
- Cache the result of GetBlockHeaders so that it can be called a few hundreds time per sec without much overhead.
- I don't have a cache invalidation strategy in mind, so that need to be resolved.
Is your feature request related to a problem? Please describe.
IForwardHeaderProvider.GetBlockHeadersreturns the currently pending canonical chain that block downloader should download and process.PowHeaderProvider, which download header directly from best peer, this call is cached, because a p2p call is just straight up too slow.PosHeaderProvider, this was not done for simplicity, preferring to callChainLevelHelperwhich re-fetch header.BlockDownloader.MaxHeaderLookupwhich limits the parallelism of block downloader. Which, is not nice, but at least much better than downloading from just a single peer.Describe the solution you'd like