Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 68eab1a

Browse files
committed
Enforce max size for dropped transaction list
1 parent 6e04540 commit 68eab1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libethereum/TransactionQueue.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ using namespace std;
2828
using namespace dev;
2929
using namespace dev::eth;
3030

31-
const size_t c_maxVerificationQueueSize = 8192;
31+
constexpr size_t c_maxVerificationQueueSize = 8192;
32+
constexpr size_t c_maxDroppedTransactionCount = 1024;
3233

3334
TransactionQueue::TransactionQueue(unsigned _limit, unsigned _futureLimit):
3435
m_current(PriorityCompare { *this }),
@@ -328,6 +329,14 @@ void TransactionQueue::drop(h256 const& _txHash)
328329
return;
329330

330331
UpgradeGuard ul(l);
332+
if (m_dropped.size() == c_maxDroppedTransactionCount)
333+
{
334+
LOG(m_loggerDetail) << "Dropped transaction list is at capacity ("
335+
<< c_maxDroppedTransactionCount
336+
<< "), removing dropped transaction from list (txhash: "
337+
<< *m_dropped.begin() << ")";
338+
m_dropped.erase(m_dropped.begin());
339+
}
331340
m_dropped.insert(_txHash);
332341
remove_WITH_LOCK(_txHash);
333342
}

0 commit comments

Comments
 (0)