Changeset View
Changeset View
Standalone View
Standalone View
src/txorphanage.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | int EraseOrphanTx(const TxId &txid) { | ||||
} | } | ||||
g_orphan_list.pop_back(); | g_orphan_list.pop_back(); | ||||
mapOrphanTransactions.erase(it); | mapOrphanTransactions.erase(it); | ||||
return 1; | return 1; | ||||
} | } | ||||
void EraseOrphansFor(NodeId peer) { | void EraseOrphansFor(NodeId peer) { | ||||
LOCK(g_cs_orphans); | AssertLockHeld(g_cs_orphans); | ||||
int nErased = 0; | int nErased = 0; | ||||
std::map<TxId, COrphanTx>::iterator iter = mapOrphanTransactions.begin(); | std::map<TxId, COrphanTx>::iterator iter = mapOrphanTransactions.begin(); | ||||
while (iter != mapOrphanTransactions.end()) { | while (iter != mapOrphanTransactions.end()) { | ||||
std::map<TxId, COrphanTx>::iterator maybeErase = | std::map<TxId, COrphanTx>::iterator maybeErase = | ||||
iter++; // increment to avoid iterator becoming invalid | iter++; // increment to avoid iterator becoming invalid | ||||
if (maybeErase->second.fromPeer == peer) { | if (maybeErase->second.fromPeer == peer) { | ||||
nErased += EraseOrphanTx(maybeErase->second.tx->GetId()); | nErased += EraseOrphanTx(maybeErase->second.tx->GetId()); | ||||
} | } | ||||
} | } | ||||
if (nErased > 0) { | if (nErased > 0) { | ||||
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, | LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, | ||||
peer); | peer); | ||||
} | } | ||||
} | } | ||||
unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { | unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { | ||||
LOCK(g_cs_orphans); | AssertLockHeld(g_cs_orphans); | ||||
unsigned int nEvicted = 0; | unsigned int nEvicted = 0; | ||||
static int64_t nNextSweep; | static int64_t nNextSweep; | ||||
int64_t nNow = GetTime(); | int64_t nNow = GetTime(); | ||||
if (nNextSweep <= nNow) { | if (nNextSweep <= nNow) { | ||||
// Sweep out expired orphan pool entries: | // Sweep out expired orphan pool entries: | ||||
int nErased = 0; | int nErased = 0; | ||||
int64_t nMinExpTime = | int64_t nMinExpTime = | ||||
Show All 29 Lines |