mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 09:55:49 +02:00
Merge bitcoin/bitcoin#22263: refactor: wrap CCoinsViewCursor in unique_ptr
7ad414f4bfdoc: add comment about CCoinsViewDBCursor constructor (James O'Beirne)0f8a5a4dd5move-only(ish): don't expose CCoinsViewDBCursor (James O'Beirne)615c1adfb0refactor: wrap CCoinsViewCursor in unique_ptr (James O'Beirne) Pull request description: I tripped over this one for a few hours at the beginning of the week, so I've sort of got a personal vendetta against `CCoinsView::Cursor()` returning a raw pointer. Specifically in the case of CCoinsViewDB, if a raw cursor is allocated and not freed, a cryptic leveldb assertion failure occurs on CCoinsViewDB destruction (`Assertion 'dummy_versions_.next_ == &dummy_versions_' failed.`). This is a pretty simple change. Related to: https://github.com/bitcoin/bitcoin/issues/21766 See also: https://github.com/google/leveldb/issues/142#issuecomment-414418135 ACKs for top commit: MarcoFalke: review ACK7ad414f4bf🔎 jonatack: re-ACK7ad414f4bfmodulo suggestion ryanofsky: Code review ACK7ad414f4bf. Two new commits look good and thanks for clarifying constructor comment Tree-SHA512: 6471d03e2de674d84b1ea0d31e25f433d52aa1aa4996f7b4aab1bd02b6bc340b15e64cc8ea07bbefefa3b5da35384ca5400cc230434e787c30931b8574c672f9
This commit is contained in:
@@ -2391,7 +2391,7 @@ static RPCHelpMan scantxoutset()
|
||||
LOCK(cs_main);
|
||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
||||
active_chainstate.ForceFlushStateToDisk();
|
||||
pcursor = std::unique_ptr<CCoinsViewCursor>(active_chainstate.CoinsDB().Cursor());
|
||||
pcursor = active_chainstate.CoinsDB().Cursor();
|
||||
CHECK_NONFATAL(pcursor);
|
||||
tip = active_chainstate.m_chain.Tip();
|
||||
CHECK_NONFATAL(tip);
|
||||
@@ -2590,7 +2590,7 @@ UniValue CreateUTXOSnapshot(NodeContext& node, CChainState& chainstate, CAutoFil
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
|
||||
}
|
||||
|
||||
pcursor = std::unique_ptr<CCoinsViewCursor>(chainstate.CoinsDB().Cursor());
|
||||
pcursor = chainstate.CoinsDB().Cursor();
|
||||
tip = chainstate.m_blockman.LookupBlockIndex(stats.hashBlock);
|
||||
CHECK_NONFATAL(tip);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user