Skip to content

Commit 08e58fa

Browse files
committed
[prep/refactor] move txorphanage to node namespace and directory
This is move-only.
1 parent bb91d23 commit 08e58fa

11 files changed

+30
-28
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
277277
node/timeoffsets.cpp
278278
node/transaction.cpp
279279
node/txdownloadman_impl.cpp
280+
node/txorphanage.cpp
280281
node/txreconciliation.cpp
281282
node/utxo_snapshot.cpp
282283
node/warnings.cpp
@@ -308,7 +309,6 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
308309
txdb.cpp
309310
txgraph.cpp
310311
txmempool.cpp
311-
txorphanage.cpp
312312
txrequest.cpp
313313
validation.cpp
314314
validationinterface.cpp

src/net_processing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <node/protocol_version.h>
3636
#include <node/timeoffsets.h>
3737
#include <node/txdownloadman.h>
38+
#include <node/txorphanage.h>
3839
#include <node/txreconciliation.h>
3940
#include <node/warnings.h>
4041
#include <policy/feerate.h>
@@ -53,7 +54,6 @@
5354
#include <sync.h>
5455
#include <tinyformat.h>
5556
#include <txmempool.h>
56-
#include <txorphanage.h>
5757
#include <uint256.h>
5858
#include <util/check.h>
5959
#include <util/strencodings.h>
@@ -533,7 +533,7 @@ class PeerManagerImpl final : public PeerManager
533533
std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index) override
534534
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
535535
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
536-
std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() override EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
536+
std::vector<node::TxOrphanage::OrphanTxBase> GetOrphanTransactions() override EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
537537
PeerManagerInfo GetInfo() const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
538538
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
539539
void RelayTransaction(const Txid& txid, const Wtxid& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
@@ -1754,7 +1754,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c
17541754
return true;
17551755
}
17561756

1757-
std::vector<TxOrphanage::OrphanTxBase> PeerManagerImpl::GetOrphanTransactions()
1757+
std::vector<node::TxOrphanage::OrphanTxBase> PeerManagerImpl::GetOrphanTransactions()
17581758
{
17591759
LOCK(m_tx_download_mutex);
17601760
return m_txdownloadman.GetOrphanTransactions();

src/net_processing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
#include <consensus/amount.h>
1010
#include <net.h>
11+
#include <node/txorphanage.h>
1112
#include <protocol.h>
1213
#include <threadsafety.h>
13-
#include <txorphanage.h>
1414
#include <validationinterface.h>
1515

1616
#include <atomic>
@@ -113,7 +113,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
113113
/** Get statistics from node state */
114114
virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
115115

116-
virtual std::vector<TxOrphanage::OrphanTxBase> GetOrphanTransactions() = 0;
116+
virtual std::vector<node::TxOrphanage::OrphanTxBase> GetOrphanTransactions() = 0;
117117

118118
/** Get peer manager info. */
119119
virtual PeerManagerInfo GetInfo() const = 0;

src/node/txdownloadman.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
#define BITCOIN_NODE_TXDOWNLOADMAN_H
77

88
#include <net.h>
9+
#include <node/txorphanage.h>
910
#include <policy/packages.h>
10-
#include <txorphanage.h>
11-
#include <util/transaction_identifier.h>
1211

1312
#include <cstdint>
1413
#include <memory>

src/node/txdownloadman_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include <consensus/validation.h>
1111
#include <kernel/chain.h>
1212
#include <net.h>
13+
#include <node/txorphanage.h>
1314
#include <primitives/transaction.h>
1415
#include <policy/packages.h>
15-
#include <txorphanage.h>
1616
#include <txrequest.h>
1717

1818
class CTxMemPool;

src/txorphanage.cpp renamed to src/node/txorphanage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <txorphanage.h>
5+
#include <node/txorphanage.h>
66

77
#include <consensus/validation.h>
88
#include <logging.h>
@@ -12,6 +12,7 @@
1212

1313
#include <cassert>
1414

15+
namespace node{
1516
bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
1617
{
1718
const Txid& hash = tx->GetHash();
@@ -361,3 +362,4 @@ void TxOrphanage::SanityCheck() const
361362
}
362363
}
363364
}
365+
} // namespace node

src/txorphanage.h renamed to src/node/txorphanage.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#ifndef BITCOIN_TXORPHANAGE_H
6-
#define BITCOIN_TXORPHANAGE_H
5+
#ifndef BITCOIN_NODE_TXORPHANAGE_H
6+
#define BITCOIN_NODE_TXORPHANAGE_H
77

88
#include <consensus/validation.h>
99
#include <net.h>
@@ -15,6 +15,7 @@
1515
#include <map>
1616
#include <set>
1717

18+
namespace node{
1819
/** Expiration time for orphan transactions */
1920
static constexpr auto ORPHAN_TX_EXPIRE_TIME{20min};
2021
/** Minimum time between orphan transactions expire time checks */
@@ -162,5 +163,5 @@ class TxOrphanage {
162163
/** Timestamp for the next scheduled sweep of expired orphans */
163164
NodeSeconds m_next_sweep{0s};
164165
};
165-
166-
#endif // BITCOIN_TXORPHANAGE_H
166+
} // namespace node
167+
#endif // BITCOIN_NODE_TXORPHANAGE_H

src/rpc/mempool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,15 +841,15 @@ static std::vector<RPCResult> OrphanDescription()
841841
};
842842
}
843843

844-
static UniValue OrphanToJSON(const TxOrphanage::OrphanTxBase& orphan)
844+
static UniValue OrphanToJSON(const node::TxOrphanage::OrphanTxBase& orphan)
845845
{
846846
UniValue o(UniValue::VOBJ);
847847
o.pushKV("txid", orphan.tx->GetHash().ToString());
848848
o.pushKV("wtxid", orphan.tx->GetWitnessHash().ToString());
849849
o.pushKV("bytes", orphan.tx->GetTotalSize());
850850
o.pushKV("vsize", GetVirtualTransactionSize(*orphan.tx));
851851
o.pushKV("weight", GetTransactionWeight(*orphan.tx));
852-
o.pushKV("entry", int64_t{TicksSinceEpoch<std::chrono::seconds>(orphan.nTimeExpire - ORPHAN_TX_EXPIRE_TIME)});
852+
o.pushKV("entry", int64_t{TicksSinceEpoch<std::chrono::seconds>(orphan.nTimeExpire - node::ORPHAN_TX_EXPIRE_TIME)});
853853
o.pushKV("expiration", int64_t{TicksSinceEpoch<std::chrono::seconds>(orphan.nTimeExpire)});
854854
UniValue from(UniValue::VARR);
855855
for (const auto fromPeer: orphan.announcers) {
@@ -899,7 +899,7 @@ static RPCHelpMan getorphantxs()
899899
{
900900
const NodeContext& node = EnsureAnyNodeContext(request.context);
901901
PeerManager& peerman = EnsurePeerman(node);
902-
std::vector<TxOrphanage::OrphanTxBase> orphanage = peerman.GetOrphanTransactions();
902+
std::vector<node::TxOrphanage::OrphanTxBase> orphanage = peerman.GetOrphanTransactions();
903903

904904
int verbosity{ParseVerbosity(request.params[0], /*default_verbosity=*/0, /*allow_bool*/false)};
905905

src/test/fuzz/txdownloadman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static bool HasRelayPermissions(NodeId peer) { return peer == 0; }
280280

281281
static void CheckInvariants(const node::TxDownloadManagerImpl& txdownload_impl, size_t max_orphan_count)
282282
{
283-
const TxOrphanage& orphanage = txdownload_impl.m_orphanage;
283+
const node::TxOrphanage& orphanage = txdownload_impl.m_orphanage;
284284

285285
// Orphanage usage should never exceed what is allowed
286286
Assert(orphanage.Size() <= max_orphan_count);

src/test/fuzz/txorphan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <consensus/validation.h>
77
#include <net_processing.h>
88
#include <node/eviction.h>
9+
#include <node/txorphanage.h>
910
#include <policy/policy.h>
1011
#include <primitives/transaction.h>
1112
#include <script/script.h>
@@ -14,7 +15,6 @@
1415
#include <test/fuzz/fuzz.h>
1516
#include <test/fuzz/util.h>
1617
#include <test/util/setup_common.h>
17-
#include <txorphanage.h>
1818
#include <uint256.h>
1919
#include <util/check.h>
2020
#include <util/time.h>
@@ -36,7 +36,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
3636
FastRandomContext orphanage_rng{/*fDeterministic=*/true};
3737
SetMockTime(ConsumeTime(fuzzed_data_provider));
3838

39-
TxOrphanage orphanage;
39+
node::TxOrphanage orphanage;
4040
std::vector<COutPoint> outpoints; // Duplicates are tolerated
4141
outpoints.reserve(200'000);
4242

0 commit comments

Comments
 (0)