mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Refactor: CTxMempool class to its own txmempool.{cpp,h}
This commit is contained in:
52
src/main.h
52
src/main.h
@@ -12,6 +12,7 @@
|
||||
#include "core.h"
|
||||
#include "bignum.h"
|
||||
#include "sync.h"
|
||||
#include "txmempool.h"
|
||||
#include "net.h"
|
||||
#include "script.h"
|
||||
|
||||
@@ -19,12 +20,11 @@
|
||||
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
class CKeyItem;
|
||||
class CReserveKey;
|
||||
|
||||
class CAddress;
|
||||
class CInv;
|
||||
class CKeyItem;
|
||||
class CNode;
|
||||
class CReserveKey;
|
||||
class CWallet;
|
||||
|
||||
/** The maximum allowed size for a serialized block, in bytes (network rule) */
|
||||
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
||||
@@ -70,8 +70,8 @@ extern CScript COINBASE_FLAGS;
|
||||
|
||||
|
||||
extern CCriticalSection cs_main;
|
||||
extern CTxMemPool mempool;
|
||||
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
|
||||
extern unsigned int nTransactionsUpdated;
|
||||
extern uint64 nLastBlockTx;
|
||||
extern uint64 nLastBlockSize;
|
||||
extern const std::string strMessageMagic;
|
||||
@@ -175,7 +175,9 @@ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned in
|
||||
/** Abort with a message */
|
||||
bool AbortNode(const std::string &msg);
|
||||
|
||||
|
||||
/** (try to) add transaction to memory pool **/
|
||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||
bool* pfMissingInputs, bool fRejectInsaneFee=false);
|
||||
|
||||
|
||||
|
||||
@@ -1029,44 +1031,6 @@ extern CChain chainActive;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CTxMemPool
|
||||
{
|
||||
public:
|
||||
static bool fChecks;
|
||||
mutable CCriticalSection cs;
|
||||
std::map<uint256, CTransaction> mapTx;
|
||||
std::map<COutPoint, CInPoint> mapNextTx;
|
||||
|
||||
bool accept(CValidationState &state, const CTransaction &tx, bool fLimitFree, bool* pfMissingInputs, bool fRejectInsaneFee = false);
|
||||
bool addUnchecked(const uint256& hash, const CTransaction &tx);
|
||||
bool remove(const CTransaction &tx, bool fRecursive = false);
|
||||
bool removeConflicts(const CTransaction &tx);
|
||||
void clear();
|
||||
void queryHashes(std::vector<uint256>& vtxid);
|
||||
void pruneSpent(const uint256& hash, CCoins &coins);
|
||||
void check(CCoinsViewCache *pcoins) const;
|
||||
|
||||
unsigned long size()
|
||||
{
|
||||
LOCK(cs);
|
||||
return mapTx.size();
|
||||
}
|
||||
|
||||
bool exists(uint256 hash)
|
||||
{
|
||||
return (mapTx.count(hash) != 0);
|
||||
}
|
||||
|
||||
CTransaction& lookup(uint256 hash)
|
||||
{
|
||||
return mapTx[hash];
|
||||
}
|
||||
};
|
||||
|
||||
extern CTxMemPool mempool;
|
||||
|
||||
struct CCoinsStats
|
||||
{
|
||||
int nHeight;
|
||||
|
||||
Reference in New Issue
Block a user