Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | if (nNextSweep <= nNow) { | ||||
// Sweep again 5 minutes after the next entry that expires in order to | // Sweep again 5 minutes after the next entry that expires in order to | ||||
// batch the linear scan. | // batch the linear scan. | ||||
nNextSweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL; | nNextSweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL; | ||||
if (nErased > 0) { | if (nErased > 0) { | ||||
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx due to expiration\n", | LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx due to expiration\n", | ||||
nErased); | nErased); | ||||
} | } | ||||
} | } | ||||
FastRandomContext rng; | |||||
while (mapOrphanTransactions.size() > nMaxOrphans) { | while (mapOrphanTransactions.size() > nMaxOrphans) { | ||||
// Evict a random orphan: | // Evict a random orphan: | ||||
uint256 randomhash = GetRandHash(); | uint256 randomhash = rng.rand256(); | ||||
std::map<uint256, COrphanTx>::iterator it = | std::map<uint256, COrphanTx>::iterator it = | ||||
mapOrphanTransactions.lower_bound(randomhash); | mapOrphanTransactions.lower_bound(randomhash); | ||||
if (it == mapOrphanTransactions.end()) { | if (it == mapOrphanTransactions.end()) { | ||||
it = mapOrphanTransactions.begin(); | it = mapOrphanTransactions.begin(); | ||||
} | } | ||||
EraseOrphanTx(it->first); | EraseOrphanTx(it->first); | ||||
++nEvicted; | ++nEvicted; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,465 Lines • Show Last 20 Lines |