Implement accurate memory accounting for mempool
This commit is contained in:
committed by
Jack Grigg
parent
a28b17b7b7
commit
bde5c8b0f1
@@ -40,6 +40,7 @@ private:
|
||||
CAmount nFee; //! Cached to avoid expensive parent-transaction lookups
|
||||
size_t nTxSize; //! ... and avoid recomputing tx size
|
||||
size_t nModSize; //! ... and modified size for priority
|
||||
size_t nUsageSize; //! ... and total memory usage
|
||||
int64_t nTime; //! Local time when entering the mempool
|
||||
double dPriority; //! Priority when entering the mempool
|
||||
unsigned int nHeight; //! Chain height when entering the mempool
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
int64_t GetTime() const { return nTime; }
|
||||
unsigned int GetHeight() const { return nHeight; }
|
||||
bool WasClearAtEntry() const { return hadNoDependencies; }
|
||||
size_t DynamicMemoryUsage() const { return nUsageSize; }
|
||||
};
|
||||
|
||||
class CBlockPolicyEstimator;
|
||||
@@ -73,6 +75,7 @@ public:
|
||||
CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; }
|
||||
void SetNull() { ptx = NULL; n = (uint32_t) -1; }
|
||||
bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); }
|
||||
size_t DynamicMemoryUsage() const { return 0; }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -93,6 +96,7 @@ private:
|
||||
CBlockPolicyEstimator* minerPolicyEstimator;
|
||||
|
||||
uint64_t totalTxSize = 0; //! sum of all mempool tx' byte sizes
|
||||
uint64_t cachedInnerUsage; //! sum of dynamic memory usage of all the map elements (NOT the maps themselves)
|
||||
|
||||
public:
|
||||
mutable CCriticalSection cs;
|
||||
@@ -141,6 +145,7 @@ public:
|
||||
LOCK(cs);
|
||||
return mapTx.size();
|
||||
}
|
||||
|
||||
uint64_t GetTotalTxSize()
|
||||
{
|
||||
LOCK(cs);
|
||||
@@ -164,6 +169,8 @@ public:
|
||||
/** Write/Read estimates to disk */
|
||||
bool WriteFeeEstimates(CAutoFile& fileout) const;
|
||||
bool ReadFeeEstimates(CAutoFile& filein);
|
||||
|
||||
size_t DynamicMemoryUsage() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user