|
|
|
@ -1261,37 +1261,9 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
|
|
|
|
|
*/
|
|
|
|
|
void PeerManagerImpl::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
LOCK(g_cs_orphans);
|
|
|
|
|
|
|
|
|
|
std::vector<uint256> vOrphanErase;
|
|
|
|
|
|
|
|
|
|
for (const CTransactionRef& ptx : pblock->vtx) {
|
|
|
|
|
const CTransaction& tx = *ptx;
|
|
|
|
|
EraseOrphansForBlock(*pblock);
|
|
|
|
|
m_last_tip_update = GetTime();
|
|
|
|
|
|
|
|
|
|
// Which orphan pool entries must we evict?
|
|
|
|
|
for (const auto& txin : tx.vin) {
|
|
|
|
|
auto itByPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
|
|
|
|
|
if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
|
|
|
|
|
for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
|
|
|
|
|
const CTransaction& orphanTx = *(*mi)->second.tx;
|
|
|
|
|
const uint256& orphanHash = orphanTx.GetHash();
|
|
|
|
|
vOrphanErase.push_back(orphanHash);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Erase orphan transactions included or precluded by this block
|
|
|
|
|
if (vOrphanErase.size()) {
|
|
|
|
|
int nErased = 0;
|
|
|
|
|
for (const uint256& orphanHash : vOrphanErase) {
|
|
|
|
|
nErased += EraseOrphanTx(orphanHash);
|
|
|
|
|
}
|
|
|
|
|
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_last_tip_update = GetTime();
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
LOCK(m_recent_confirmed_transactions_mutex);
|
|
|
|
|
for (const auto& ptx : pblock->vtx) {
|
|
|
|
|