Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_TXMEMPOOL_H | #ifndef BITCOIN_TXMEMPOOL_H | ||||
#define BITCOIN_TXMEMPOOL_H | #define BITCOIN_TXMEMPOOL_H | ||||
#include <map> | |||||
#include <memory> | |||||
#include <set> | |||||
#include <string> | |||||
#include <utility> | |||||
#include <vector> | |||||
#include "amount.h" | #include "amount.h" | ||||
#include "coins.h" | #include "coins.h" | ||||
#include "indirectmap.h" | #include "indirectmap.h" | ||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include "random.h" | #include "random.h" | ||||
#include "sync.h" | #include "sync.h" | ||||
#include <boost/multi_index/hashed_index.hpp> | #include <boost/multi_index/hashed_index.hpp> | ||||
#include <boost/multi_index/ordered_index.hpp> | #include <boost/multi_index/ordered_index.hpp> | ||||
#include <boost/multi_index_container.hpp> | #include <boost/multi_index_container.hpp> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
#include <map> | |||||
#include <memory> | |||||
#include <set> | |||||
#include <string> | |||||
#include <utility> | |||||
#include <vector> | |||||
class CAutoFile; | class CAutoFile; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
class Config; | class Config; | ||||
inline double AllowFreeThreshold() { | inline double AllowFreeThreshold() { | ||||
return COIN.GetSatoshis() * 144 / 250; | return COIN.GetSatoshis() * 144 / 250; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 754 Lines • ▼ Show 20 Lines | |||||
* It does not check for spendings by memory pool transactions. | * It does not check for spendings by memory pool transactions. | ||||
*/ | */ | ||||
class CCoinsViewMemPool : public CCoinsViewBacked { | class CCoinsViewMemPool : public CCoinsViewBacked { | ||||
protected: | protected: | ||||
const CTxMemPool &mempool; | const CTxMemPool &mempool; | ||||
public: | public: | ||||
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); | CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); | ||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const; | bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; | ||||
bool HaveCoin(const COutPoint &outpoint) const; | bool HaveCoin(const COutPoint &outpoint) const override; | ||||
}; | }; | ||||
// We want to sort transactions by coin age priority | // We want to sort transactions by coin age priority | ||||
typedef std::pair<double, CTxMemPool::txiter> TxCoinAgePriority; | typedef std::pair<double, CTxMemPool::txiter> TxCoinAgePriority; | ||||
struct TxCoinAgePriorityCompare { | struct TxCoinAgePriorityCompare { | ||||
bool operator()(const TxCoinAgePriority &a, const TxCoinAgePriority &b) { | bool operator()(const TxCoinAgePriority &a, const TxCoinAgePriority &b) { | ||||
if (a.first == b.first) { | if (a.first == b.first) { | ||||
// Reverse order to make sort less than | // Reverse order to make sort less than | ||||
return CompareTxMemPoolEntryByScore()(*(b.second), *(a.second)); | return CompareTxMemPoolEntryByScore()(*(b.second), *(a.second)); | ||||
} | } | ||||
return a.first < b.first; | return a.first < b.first; | ||||
} | } | ||||
}; | }; | ||||
#endif // BITCOIN_TXMEMPOOL_H | #endif // BITCOIN_TXMEMPOOL_H |