#include <list>
+#include "addressindex.h"
+#include "spentindex.h"
#include "amount.h"
#include "coins.h"
#include "primitives/transaction.h"
#include "sync.h"
+#include "addressindex.h"
+#include "spentindex.h"
#undef foreach
#include "boost/multi_index_container.hpp"
#include "boost/multi_index/ordered_index.hpp"
+#include "pbaas/reserves.h"
+
class CAutoFile;
inline double AllowFreeThreshold()
{
private:
CTransaction tx;
- 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
- CFeeRate feeRate; //!< ... and fee per kB
- 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
- bool hadNoDependencies; //!< Not dependent on any other txs when it entered the mempool
- bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
- uint32_t nBranchId; //!< Branch ID this transaction is known to commit to, cached for efficiency
+ 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
+ CFeeRate feeRate; //! ... and fee per kB
+ 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
+ bool hadNoDependencies; //! Not dependent on any other txs when it entered the mempool
+ bool spendsCoinbase; //! keep track of transactions that spend a coinbase
+ bool hasReserve; //! keep track of transactions that hold reserve currency
+ uint32_t nBranchId; //! Branch ID this transaction is known to commit to, cached for efficiency
public:
CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
int64_t _nTime, double _dPriority, unsigned int _nHeight,
- bool poolHasNoInputsOf, bool spendsCoinbase, uint32_t nBranchId);
+ bool poolHasNoInputsOf, bool spendsCoinbase, uint32_t nBranchId, bool hasreserve=false);
CTxMemPoolEntry();
CTxMemPoolEntry(const CTxMemPoolEntry& other);
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)
+ std::map<uint256, const CTransaction*> mapRecentlyAddedTx;
+ uint64_t nRecentlyAddedSequence = 0;
+ uint64_t nNotifiedSequence = 0;
+
std::map<uint256, const CTransaction*> mapSproutNullifiers;
std::map<uint256, const CTransaction*> mapSaplingNullifiers;
+ std::map<uint256, std::pair<double, CAmount> > mapDeltas;
+ std::map<uint256, CReserveTransactionDescriptor> mapReserveTransactions; // all reserve transactions in the mempool go here
+
void checkNullifiers(ShieldedType type) const;
public:
mutable CCriticalSection cs;
indexed_transaction_set mapTx;
+
+private:
+ std::map<CMempoolAddressDeltaKey, CMempoolAddressDelta, CMempoolAddressDeltaKeyCompare> mapAddress;
+ std::map<uint256, std::vector<CMempoolAddressDeltaKey> > mapAddressInserted;
+ std::map<CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare> mapSpent;
+ std::map<uint256, std::vector<CSpentIndexKey>> mapSpentInserted;
+
+public:
std::map<COutPoint, CInPoint> mapNextTx;
- std::map<uint256, std::pair<double, CAmount> > mapDeltas;
CTxMemPool(const CFeeRate& _minRelayFee);
~CTxMemPool();
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = static_cast<uint32_t>(dFrequency * 4294967295.0); }
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
+ void addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
+ bool getAddressIndex(const std::vector<std::pair<uint160, int> > &addresses, std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results);
+ bool removeAddressIndex(const uint256 txhash);
+
+ void addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
+ bool getSpentIndex(const CSpentIndexKey &key, CSpentIndexValue &value);
+ bool removeSpentIndex(const uint256 txhash);
void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
void removeWithAnchor(const uint256 &invalidRoot, ShieldedType type);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
+ bool checkNameConflicts(const CTransaction &tx, std::list<CTransaction> &conflicting);
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
void removeExpired(unsigned int nBlockHeight);
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
bool HasNoInputsOf(const CTransaction& tx) const;
/** Affect CreateNewBlock prioritisation of transactions */
- void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
+ void PrioritiseTransaction(const uint256 &hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
+ bool PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyState ¤cyState);
+ bool IsKnownReserveTransaction(const uint256 &hash, CReserveTransactionDescriptor &txDesc); // know to be reserve transaction, get descriptor, update mempool
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta);
void ClearPrioritisation(const uint256 hash);
bool nullifierExists(const uint256& nullifier, ShieldedType type) const;
+ void NotifyRecentlyAdded();
+ bool IsFullyNotified();
+
unsigned long size()
{
LOCK(cs);