diff options
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 73 |
1 files changed, 8 insertions, 65 deletions
diff --git a/src/main.h b/src/main.h index b56a4a5e19..80972330f3 100644 --- a/src/main.h +++ b/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,14 +20,11 @@ class CBlock; class CBlockIndex; -class CKeyItem; -class CReserveKey; - -class CAddress; class CInv; +class CKeyItem; class CNode; - -struct CBlockIndexWorkComparator; +class CReserveKey; +class CWallet; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 1000000; @@ -72,10 +70,8 @@ extern CScript COINBASE_FLAGS; extern CCriticalSection cs_main; +extern CTxMemPool mempool; extern std::map<uint256, CBlockIndex*> mapBlockIndex; -extern std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; -extern uint256 nBestInvalidWork; -extern unsigned int nTransactionsUpdated; extern uint64 nLastBlockTx; extern uint64 nLastBlockSize; extern const std::string strMessageMagic; @@ -179,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); @@ -647,10 +645,6 @@ public: } }; -extern CCriticalSection cs_LastBlockFile; -extern CBlockFileInfo infoLastBlockFile; -extern int nLastBlockFile; - enum BlockStatus { BLOCK_VALID_UNKNOWN = 0, BLOCK_VALID_HEADER = 1, // parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future @@ -850,19 +844,6 @@ public: } }; -struct CBlockIndexWorkComparator -{ - bool operator()(CBlockIndex *pa, CBlockIndex *pb) { - if (pa->nChainWork > pb->nChainWork) return false; - if (pa->nChainWork < pb->nChainWork) return true; - - if (pa->GetBlockHash() < pb->GetBlockHash()) return false; - if (pa->GetBlockHash() > pb->GetBlockHash()) return true; - - return false; // identical blocks - } -}; - /** Used to marshal pointers into hashes for db storage. */ @@ -1050,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; |