Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
// Copyright (c) 2018 The Bitcoin Core developers | // Copyright (c) 2018 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. | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <policy/mempool.h> | |||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <threadsafety.h> | #include <threadsafety.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | public: | ||||
auto it_mp = ::g_mempool.mapTx.find(txid); | auto it_mp = ::g_mempool.mapTx.find(txid); | ||||
return it_mp != ::g_mempool.mapTx.end() && | return it_mp != ::g_mempool.mapTx.end() && | ||||
it_mp->GetCountWithDescendants() > 1; | it_mp->GetCountWithDescendants() > 1; | ||||
} | } | ||||
void getTransactionAncestry(const TxId &txid, size_t &ancestors, | void getTransactionAncestry(const TxId &txid, size_t &ancestors, | ||||
size_t &descendants) override { | size_t &descendants) override { | ||||
::g_mempool.GetTransactionAncestry(txid, ancestors, descendants); | ::g_mempool.GetTransactionAncestry(txid, ancestors, descendants); | ||||
} | } | ||||
bool checkChainLimits(CTransactionRef tx) override { | |||||
LockPoints lp; | |||||
CTxMemPoolEntry entry(tx, Amount(), 0, 0, false, 0, lp); | |||||
CTxMemPool::setEntries ancestors; | |||||
auto limit_ancestor_count = | |||||
gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); | |||||
auto limit_ancestor_size = | |||||
gArgs.GetArg("-limitancestorsize", | |||||
DEFAULT_ANCESTOR_SIZE_LIMIT) * | |||||
1000; | |||||
auto limit_descendant_count = | |||||
gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); | |||||
auto limit_descendant_size = | |||||
gArgs.GetArg("-limitdescendantsize", | |||||
DEFAULT_DESCENDANT_SIZE_LIMIT) * | |||||
1000; | |||||
std::string unused_error_string; | |||||
LOCK(::g_mempool.cs); | |||||
return ::g_mempool.CalculateMemPoolAncestors( | |||||
entry, ancestors, limit_ancestor_count, limit_ancestor_size, | |||||
limit_descendant_count, limit_descendant_size, | |||||
unused_error_string); | |||||
} | |||||
}; | }; | ||||
} // namespace | } // namespace | ||||
std::unique_ptr<Chain> MakeChain() { | std::unique_ptr<Chain> MakeChain() { | ||||
return std::make_unique<ChainImpl>(); | return std::make_unique<ChainImpl>(); | ||||
} | } | ||||
} // namespace interfaces | } // namespace interfaces |