mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
validation: Move block into BlockDisconnected signal
This makes existing behaviour of the block's destructor triggering on the scheduler thread more explicit by moving it to the thread. The scheduler thread doing so is useful, since it does not block the thread doing validation while releasing a block's memory. DisconnectTip already creates and destroys the block itself, so moving it into the validation signals is well scoped.
This commit is contained in:
@@ -241,12 +241,12 @@ void ValidationSignals::MempoolTransactionsRemovedForBlock(const std::vector<Rem
|
||||
ENQUEUE_AND_LOG_EVENT(std::move(event), std::move(log_msg));
|
||||
}
|
||||
|
||||
void ValidationSignals::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
void ValidationSignals::BlockDisconnected(std::shared_ptr<const CBlock> pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
auto log_msg = LOG_MSG("%s: block hash=%s block height=%d", __func__,
|
||||
pblock->GetHash().ToString(),
|
||||
pindex->nHeight);
|
||||
auto event = [pblock, pindex, this] {
|
||||
auto event = [pblock = std::move(pblock), pindex, this] {
|
||||
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.BlockDisconnected(pblock, pindex); });
|
||||
};
|
||||
ENQUEUE_AND_LOG_EVENT(std::move(event), std::move(log_msg));
|
||||
|
||||
Reference in New Issue
Block a user