mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
kernel: improve BlockChecked ownership semantics
Subscribers to the BlockChecked validation interface event may need access to the block outside of the callback scope. Currently, this is only possible by copying the block, which makes exposing this validation interface event publicly either cumbersome or with significant copy overhead. By using shared_ptr, we make the shared ownership explicit and allow users to safely use the block outside of the callback scope.
This commit is contained in:
@@ -3178,7 +3178,7 @@ bool Chainstate::ConnectTip(
|
||||
CCoinsViewCache view(&CoinsTip());
|
||||
bool rv = ConnectBlock(*block_to_connect, state, pindexNew, view);
|
||||
if (m_chainman.m_options.signals) {
|
||||
m_chainman.m_options.signals->BlockChecked(*block_to_connect, state);
|
||||
m_chainman.m_options.signals->BlockChecked(block_to_connect, state);
|
||||
}
|
||||
if (!rv) {
|
||||
if (state.IsInvalid())
|
||||
@@ -4554,7 +4554,7 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
|
||||
}
|
||||
if (!ret) {
|
||||
if (m_options.signals) {
|
||||
m_options.signals->BlockChecked(*block, state);
|
||||
m_options.signals->BlockChecked(block, state);
|
||||
}
|
||||
LogError("%s: AcceptBlock FAILED (%s)\n", __func__, state.ToString());
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user