Create a txgraph inside CTxMemPool
This commit is contained in:
1 parent
29a94d5b2f
commit
c18c68a950
2 files changed
+9
-1
No files matched your search
+2
-1
@@ -413,6 +413,7 @@ static CTxMemPool::Options&& Flatten(CTxMemPool::Options&& opts, bilingual_str&
|
|||||||
CTxMemPool::CTxMemPool(Options opts, bilingual_str& error)
|
CTxMemPool::CTxMemPool(Options opts, bilingual_str& error)
|
||||||
: m_opts{Flatten(std::move(opts), error)}
|
: m_opts{Flatten(std::move(opts), error)}
|
||||||
{
|
{
|
||||||
|
m_txgraph = MakeTxGraph(64, 101'000, ACCEPTABLE_ITERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTxMemPool::isSpent(const COutPoint& outpoint) const
|
bool CTxMemPool::isSpent(const COutPoint& outpoint) const
|
||||||
@@ -1042,7 +1043,7 @@ void CCoinsViewMemPool::Reset()
|
|||||||
size_t CTxMemPool::DynamicMemoryUsage() const {
|
size_t CTxMemPool::DynamicMemoryUsage() const {
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
// Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
|
// Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
|
||||||
return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + cachedInnerUsage;
|
return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + m_txgraph->GetMainMemoryUsage() + cachedInnerUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::RemoveUnbroadcastTx(const Txid& txid, const bool unchecked) {
|
void CTxMemPool::RemoveUnbroadcastTx(const Txid& txid, const bool unchecked) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <primitives/transaction_identifier.h>
|
#include <primitives/transaction_identifier.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
|
#include <txgraph.h>
|
||||||
#include <util/epochguard.h>
|
#include <util/epochguard.h>
|
||||||
#include <util/feefrac.h>
|
#include <util/feefrac.h>
|
||||||
#include <util/hasher.h>
|
#include <util/hasher.h>
|
||||||
@@ -49,6 +50,11 @@ struct bilingual_str;
|
|||||||
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
|
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
|
||||||
static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
|
static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
|
||||||
|
|
||||||
|
/** How many linearization iterations required for TxGraph clusters to have
|
||||||
|
* "acceptable" quality, if they cannot be optimally linearized with fewer
|
||||||
|
* iterations. */
|
||||||
|
static constexpr uint64_t ACCEPTABLE_ITERS = 1'700;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether the LockPoints height and time are still valid on the current chain
|
* Test whether the LockPoints height and time are still valid on the current chain
|
||||||
*/
|
*/
|
||||||
@@ -376,6 +382,7 @@ public:
|
|||||||
|
|
||||||
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
private:
|
private:
|
||||||
|
std::unique_ptr<TxGraph> m_txgraph GUARDED_BY(cs);
|
||||||
typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
|
typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user