mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-11 08:07:33 +02:00
validation: reuse same CCoinsViewCache for every ConnectBlock call
Add m_connect_block_view to ChainState's CoinsViews. Call CreateResetGuard inside ConnectTip to ensure the view is Reset after each block, avoiding repeated memory allocations. Co-authored-by: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -488,6 +488,10 @@ public:
|
||||
//! can fit per the dbcache setting.
|
||||
std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
|
||||
|
||||
//! Temporary CCoinsViewCache layered on top of m_cacheview and passed to ConnectBlock().
|
||||
//! Reset between calls and flushed only on success, so invalid blocks don't pollute the underlying cache.
|
||||
std::unique_ptr<CCoinsViewCache> m_connect_block_view GUARDED_BY(cs_main);
|
||||
|
||||
//! This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it
|
||||
//! *does not* create a CCoinsViewCache instance by default. This is done separately because the
|
||||
//! presence of the cache has implications on whether or not we're allowed to flush the cache's
|
||||
|
||||
Reference in New Issue
Block a user