aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-10-27 08:42:24 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-10-27 08:48:12 +0100
commit38369dda325d704041e7eb43222cdd5c23daa7c3 (patch)
tree06e7c2f32145e6620c61f9a504436efbf99969b5 /src
parent2b625510d37471d4eaf5f99c2311afbdcae448c2 (diff)
parent0d699fc821048ab9316b0004e6552c8f1dc5e5f4 (diff)
downloadbitcoin-38369dda325d704041e7eb43222cdd5c23daa7c3.tar.xz
Merge pull request #6889
0d699fc fix locking issue with new mempool limiting (Jonas Schnelli)
Diffstat (limited to 'src')
-rw-r--r--src/txmempool.cpp11
-rw-r--r--src/txmempool.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index bb148005cd..efa5c8f7a3 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -309,7 +309,7 @@ void CTxMemPoolEntry::UpdateState(int64_t modifySize, CAmount modifyFee, int64_t
CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
nTransactionsUpdated(0)
{
- clear();
+ _clear(); //lock free clear
// Sanity checks off by default for performance, because otherwise
// accepting transactions becomes O(N^2) where N is the number
@@ -546,9 +546,8 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
blockSinceLastRollingFeeBump = true;
}
-void CTxMemPool::clear()
+void CTxMemPool::_clear()
{
- LOCK(cs);
mapLinks.clear();
mapTx.clear();
mapNextTx.clear();
@@ -560,6 +559,12 @@ void CTxMemPool::clear()
++nTransactionsUpdated;
}
+void CTxMemPool::clear()
+{
+ LOCK(cs);
+ _clear();
+}
+
void CTxMemPool::check(const CCoinsViewCache *pcoins) const
{
if (!fSanityCheck)
diff --git a/src/txmempool.h b/src/txmempool.h
index d44995eefe..dedc7ba72c 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -375,6 +375,7 @@ public:
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
void clear();
+ void _clear(); //lock free
void queryHashes(std::vector<uint256>& vtxid);
void pruneSpent(const uint256& hash, CCoins &coins);
unsigned int GetTransactionsUpdated() const;