Guard fetch_mainchain_block calls with is_main_thread(), Speed up MSAN sync test

This commit is contained in:
Matt Hess
2025-12-25 17:44:55 +00:00
parent 7ee7e0c71d
commit d4cd458cdf
2 changed files with 16 additions and 11 deletions
+11 -6
View File
@@ -633,16 +633,21 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
}
else {
LOGWARN(3, "add_external_block: block is built on top of an unknown mainchain block " << block.m_prevId << ", mainchain reorg might've happened, fetching mainchain height " << block.m_txinGenHeight);
// Fetch the mainchain block at the claimed height
m_pool->fetch_mainchain_block(block.m_txinGenHeight);
// Fetch the mainchain block at the claimed height (only from main thread to avoid libuv threading issues)
if (is_main_thread()) {
m_pool->fetch_mainchain_block(block.m_txinGenHeight);
}
}
if (!m_pool->get_seed(block.m_txinGenHeight, block.m_seed)) {
LOGWARN(3, "add_external_block mined by " << block.m_minerWallet << ": couldn't get seed hash for mainchain height " << block.m_txinGenHeight << ", fetching it from salviumd");
// Fetch the missing mainchain block on-demand
const uint64_t seed_height = p2pool::get_seed_height(block.m_txinGenHeight);
m_pool->fetch_mainchain_block(seed_height);
forget_incoming_block(block);
// Fetch the missing mainchain block on-demand (only from main thread to avoid libuv threading issues)
if (is_main_thread()) {
const uint64_t seed_height = p2pool::get_seed_height(block.m_txinGenHeight);
m_pool->fetch_mainchain_block(seed_height);
forget_incoming_block(block);
}
// If not on main thread, don't forget - block stays pending until mainchain data arrives via prefetch
return false;
}