|
6 | 6 |
|
7 | 7 | #include <chain.h> |
8 | 8 | #include <chainparams.h> |
| 9 | +#include <interfaces/wallet.h> |
| 10 | +#include <net.h> |
| 11 | +#include <policy/fees.h> |
| 12 | +#include <policy/policy.h> |
9 | 13 | #include <primitives/block.h> |
| 14 | +#include <primitives/transaction.h> |
| 15 | +#include <protocol.h> |
10 | 16 | #include <sync.h> |
| 17 | +#include <threadsafety.h> |
| 18 | +#include <timedata.h> |
| 19 | +#include <txmempool.h> |
| 20 | +#include <ui_interface.h> |
11 | 21 | #include <uint256.h> |
12 | 22 | #include <util/system.h> |
13 | 23 | #include <validation.h> |
@@ -132,6 +142,17 @@ class LockImpl : public Chain::Lock |
132 | 142 | } |
133 | 143 | return nullopt; |
134 | 144 | } |
| 145 | + bool checkFinalTx(const CTransaction& tx) override |
| 146 | + { |
| 147 | + LockAnnotation lock(::cs_main); |
| 148 | + return CheckFinalTx(tx); |
| 149 | + } |
| 150 | + bool submitToMemoryPool(CTransactionRef tx, CAmount absurd_fee, CValidationState& state) override |
| 151 | + { |
| 152 | + LockAnnotation lock(::cs_main); |
| 153 | + return AcceptToMemoryPool(mempool, state, tx, nullptr /* missing inputs */, |
| 154 | + false /* bypass limits */, absurd_fee); |
| 155 | + } |
135 | 156 | }; |
136 | 157 |
|
137 | 158 | class LockingStateImpl : public LockImpl, public UniqueLock<CCriticalSection> |
@@ -177,6 +198,56 @@ class ChainImpl : public Chain |
177 | 198 | LOCK(cs_main); |
178 | 199 | return GuessVerificationProgress(Params().TxData(), LookupBlockIndex(block_hash)); |
179 | 200 | } |
| 201 | + void relayTransaction(const uint256& txid) override |
| 202 | + { |
| 203 | + CInv inv(MSG_TX, txid); |
| 204 | + g_connman->ForEachNode([&inv](CNode* node) { node->PushInventory(inv); }); |
| 205 | + } |
| 206 | + void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override |
| 207 | + { |
| 208 | + ::mempool.GetTransactionAncestry(txid, ancestors, descendants); |
| 209 | + } |
| 210 | + bool checkChainLimits(CTransactionRef tx) override |
| 211 | + { |
| 212 | + LockPoints lp; |
| 213 | + CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp); |
| 214 | + CTxMemPool::setEntries ancestors; |
| 215 | + auto limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); |
| 216 | + auto limit_ancestor_size = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000; |
| 217 | + auto limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); |
| 218 | + auto limit_descendant_size = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000; |
| 219 | + std::string unused_error_string; |
| 220 | + LOCK(::mempool.cs); |
| 221 | + return ::mempool.CalculateMemPoolAncestors(entry, ancestors, limit_ancestor_count, limit_ancestor_size, |
| 222 | + limit_descendant_count, limit_descendant_size, unused_error_string); |
| 223 | + } |
| 224 | + CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override |
| 225 | + { |
| 226 | + return ::feeEstimator.estimateSmartFee(num_blocks, calc, conservative); |
| 227 | + } |
| 228 | + unsigned int estimateMaxBlocks() override |
| 229 | + { |
| 230 | + return ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE); |
| 231 | + } |
| 232 | + CFeeRate mempoolMinFee() override |
| 233 | + { |
| 234 | + return ::mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); |
| 235 | + } |
| 236 | + bool hasDescendantsInMempool(const uint256& txid) override |
| 237 | + { |
| 238 | + LOCK(::mempool.cs); |
| 239 | + auto it_mp = ::mempool.mapTx.find(txid); |
| 240 | + return it_mp != ::mempool.mapTx.end() && it_mp->GetCountWithDescendants() > 1; |
| 241 | + } |
| 242 | + CAmount maxTxFee() override { return ::maxTxFee; } |
| 243 | + bool getPruneMode() override { return ::fPruneMode; } |
| 244 | + bool p2pEnabled() override { return g_connman != nullptr; } |
| 245 | + bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); } |
| 246 | + int64_t getAdjustedTime() override { return GetAdjustedTime(); } |
| 247 | + void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); } |
| 248 | + void initWarning(const std::string& message) override { InitWarning(message); } |
| 249 | + void initError(const std::string& message) override { InitError(message); } |
| 250 | + void loadWallet(std::unique_ptr<Wallet> wallet) override { ::uiInterface.LoadWallet(wallet); } |
180 | 251 | }; |
181 | 252 |
|
182 | 253 | } // namespace |
|
0 commit comments