Skip to content

Commit 575bbd0

Browse files
committed
[net processing] Move tx relay data to Peer
1 parent 785f55f commit 575bbd0

File tree

8 files changed

+141
-175
lines changed

8 files changed

+141
-175
lines changed

src/net.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,6 @@ void CNode::CopyStats(CNodeStats& stats)
626626
X(addr);
627627
X(addrBind);
628628
stats.m_network = ConnectedThroughNetwork();
629-
if (m_tx_relay != nullptr) {
630-
LOCK(m_tx_relay->cs_filter);
631-
stats.fRelayTxes = m_tx_relay->fRelayTxes;
632-
} else {
633-
stats.fRelayTxes = false;
634-
}
635629
X(m_last_send);
636630
X(m_last_recv);
637631
X(m_last_tx_time);
@@ -658,11 +652,6 @@ void CNode::CopyStats(CNodeStats& stats)
658652
X(nRecvBytes);
659653
}
660654
X(m_permissionFlags);
661-
if (m_tx_relay != nullptr) {
662-
stats.minFeeFilter = m_tx_relay->minFeeFilter;
663-
} else {
664-
stats.minFeeFilter = 0;
665-
}
666655

667656
X(m_last_ping_time);
668657
X(m_min_ping_time);
@@ -3024,9 +3013,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, std::shared_ptr<Sock> s
30243013
nLocalServices(nLocalServicesIn)
30253014
{
30263015
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
3027-
if (conn_type_in != ConnectionType::BLOCK_RELAY) {
3028-
m_tx_relay = std::make_unique<TxRelay>();
3029-
}
30303016

30313017
for (const std::string &msg : getAllNetMessageTypes())
30323018
mapRecvBytesPerMsgCmd[msg] = 0;

src/net.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ class CNodeStats
250250
public:
251251
NodeId nodeid;
252252
ServiceFlags nServices;
253-
bool fRelayTxes;
254253
std::chrono::seconds m_last_send;
255254
std::chrono::seconds m_last_recv;
256255
std::chrono::seconds m_last_tx_time;
@@ -271,7 +270,6 @@ class CNodeStats
271270
NetPermissionFlags m_permissionFlags;
272271
std::chrono::microseconds m_last_ping_time;
273272
std::chrono::microseconds m_min_ping_time;
274-
CAmount minFeeFilter;
275273
// Our address, as reported by the peer
276274
std::string addrLocal;
277275
// Address of this peer
@@ -548,35 +546,6 @@ class CNode
548546
// Peer selected us as (compact blocks) high-bandwidth peer (BIP152)
549547
std::atomic<bool> m_bip152_highbandwidth_from{false};
550548

551-
struct TxRelay {
552-
mutable RecursiveMutex cs_filter;
553-
// We use fRelayTxes for two purposes -
554-
// a) it allows us to not relay tx invs before receiving the peer's version message
555-
// b) the peer may tell us in its version message that we should not relay tx invs
556-
// unless it loads a bloom filter.
557-
bool fRelayTxes GUARDED_BY(cs_filter){false};
558-
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter) GUARDED_BY(cs_filter){nullptr};
559-
560-
mutable RecursiveMutex cs_tx_inventory;
561-
CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_tx_inventory){50000, 0.000001};
562-
// Set of transaction ids we still have to announce.
563-
// They are sorted by the mempool before relay, so the order is not important.
564-
std::set<uint256> setInventoryTxToSend;
565-
// Used for BIP35 mempool sending
566-
bool fSendMempool GUARDED_BY(cs_tx_inventory){false};
567-
// Last time a "MEMPOOL" request was serviced.
568-
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
569-
std::chrono::microseconds nNextInvSend{0};
570-
571-
/** Minimum fee rate with which to filter inv's to this node */
572-
std::atomic<CAmount> minFeeFilter{0};
573-
CAmount lastSentFeeFilter{0};
574-
std::chrono::microseconds m_next_send_feefilter{0};
575-
};
576-
577-
// m_tx_relay == nullptr if we're not relaying transactions with this peer
578-
std::unique_ptr<TxRelay> m_tx_relay;
579-
580549
/** Whether we should relay transactions to this peer (their version
581550
* message did not include fRelay=false and this is not a block-relay-only
582551
* connection). This only changes from false to true. It will never change
@@ -661,23 +630,6 @@ class CNode
661630
nRefCount--;
662631
}
663632

664-
void AddKnownTx(const uint256& hash)
665-
{
666-
if (m_tx_relay != nullptr) {
667-
LOCK(m_tx_relay->cs_tx_inventory);
668-
m_tx_relay->filterInventoryKnown.insert(hash);
669-
}
670-
}
671-
672-
void PushTxInventory(const uint256& hash)
673-
{
674-
if (m_tx_relay == nullptr) return;
675-
LOCK(m_tx_relay->cs_tx_inventory);
676-
if (!m_tx_relay->filterInventoryKnown.contains(hash)) {
677-
m_tx_relay->setInventoryTxToSend.insert(hash);
678-
}
679-
}
680-
681633
void CloseSocketDisconnect();
682634

683635
void CopyStats(CNodeStats& stats);

0 commit comments

Comments
 (0)