Skip to content

Commit 567c4e0

Browse files
committed
[net processing] Move -maxorphantx to PeerManager::Options
1 parent fa9e6d8 commit 567c4e0

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,8 +4238,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42384238
m_txrequest.ForgetTxHash(tx.GetWitnessHash());
42394239

42404240
// DoS prevention: do not allow m_orphanage to grow unbounded (see CVE-2012-3789)
4241-
unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, gArgs.GetIntArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
4242-
m_orphanage.LimitOrphans(nMaxOrphanTx);
4241+
m_orphanage.LimitOrphans(m_opts.max_orphan_txs);
42434242
} else {
42444243
LogPrint(BCLog::MEMPOOL, "not keeping orphan with rejected parents %s\n",tx.GetHash().ToString());
42454244
// We will continue to reject this tx since it has rejected

src/net_processing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
4949
/** Whether this node is running in -blocksonly mode */
5050
bool ignore_incoming_txs{DEFAULT_BLOCKSONLY};
5151
bool reconcile_txs{DEFAULT_TXRECONCILIATION_ENABLE};
52+
uint32_t max_orphan_txs{DEFAULT_MAX_ORPHAN_TRANSACTIONS};
5253
};
5354

5455
static std::unique_ptr<PeerManager> make(CConnman& connman, AddrMan& addrman,

src/node/peerman_args.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ namespace node {
77

88
void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& options)
99
{
10-
if(auto value{argsman.GetBoolArg("-txreconciliation")}) options.reconcile_txs = *value;
10+
if (auto value{argsman.GetBoolArg("-txreconciliation")}) options.reconcile_txs = *value;
11+
12+
if (auto value{argsman.GetIntArg("-maxorphantx")}) {
13+
options.max_orphan_txs = uint32_t(std::max(int64_t{0}, *value));
14+
}
1115
}
1216

1317
} // namespace node

0 commit comments

Comments
 (0)