mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
partial bitcoin#22778: Reduce resource usage for inbound block-relay-only connections
includes: - 290a8dab0288344fa5731ec2ffd09478e9420a2f
This commit is contained in:
parent
85c4aef9cb
commit
60b5392d92
@ -272,25 +272,34 @@ struct Peer {
|
|||||||
|
|
||||||
struct TxRelay {
|
struct TxRelay {
|
||||||
mutable RecursiveMutex m_bloom_filter_mutex;
|
mutable RecursiveMutex m_bloom_filter_mutex;
|
||||||
// We use m_relay_txs for two purposes -
|
/** Whether the peer wishes to receive transaction announcements.
|
||||||
// a) it allows us to not relay tx invs before receiving the peer's version message
|
*
|
||||||
// b) the peer may tell us in its version message that we should not relay tx invs
|
* This is initially set based on the fRelay flag in the received
|
||||||
// unless it loads a bloom filter.
|
* `version` message. If initially set to false, it can only be flipped
|
||||||
|
* to true if we have offered the peer NODE_BLOOM services and it sends
|
||||||
|
* us a `filterload` or `filterclear` message. See BIP37. */
|
||||||
bool m_relay_txs GUARDED_BY(m_bloom_filter_mutex){false};
|
bool m_relay_txs GUARDED_BY(m_bloom_filter_mutex){false};
|
||||||
|
/** A bloom filter for which transactions to announce to the peer. See BIP37. */
|
||||||
std::unique_ptr<CBloomFilter> m_bloom_filter PT_GUARDED_BY(m_bloom_filter_mutex) GUARDED_BY(m_bloom_filter_mutex){nullptr};
|
std::unique_ptr<CBloomFilter> m_bloom_filter PT_GUARDED_BY(m_bloom_filter_mutex) GUARDED_BY(m_bloom_filter_mutex){nullptr};
|
||||||
|
|
||||||
mutable RecursiveMutex m_tx_inventory_mutex;
|
mutable RecursiveMutex m_tx_inventory_mutex;
|
||||||
// inventory based relay
|
/** A filter of all the txids that the peer has announced to
|
||||||
|
* us or we have announced to the peer. We use this to avoid announcing
|
||||||
|
* the same txid to a peer that already has the transaction. */
|
||||||
CRollingBloomFilter m_tx_inventory_known_filter GUARDED_BY(m_tx_inventory_mutex){50000, 0.000001};
|
CRollingBloomFilter m_tx_inventory_known_filter GUARDED_BY(m_tx_inventory_mutex){50000, 0.000001};
|
||||||
// Set of transaction ids we still have to announce.
|
/** Set of transaction ids we still have to announce. We use the
|
||||||
// They are sorted by the mempool before relay, so the order is not important.
|
* mempool to sort transactions in dependency order before relay, so
|
||||||
|
* this does not have to be sorted. */
|
||||||
std::set<uint256> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
|
std::set<uint256> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
|
||||||
// List of non-tx/non-block inventory items
|
/** List of non-tx/non-block inventory items */
|
||||||
std::vector<CInv> vInventoryOtherToSend GUARDED_BY(m_tx_inventory_mutex);
|
std::vector<CInv> vInventoryOtherToSend GUARDED_BY(m_tx_inventory_mutex);
|
||||||
// Used for BIP35 mempool sending, also protected by m_tx_inventory_mutex
|
/** Whether the peer has requested us to send our complete mempool. Only
|
||||||
|
* permitted if the peer has NetPermissionFlags::Mempool. See BIP35. */
|
||||||
bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
|
bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
|
||||||
// Last time a "MEMPOOL" request was serviced.
|
/** The last time a BIP35 `mempool` request was serviced. */
|
||||||
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
|
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
|
||||||
|
/** The next time after which we will send an `inv` message containing
|
||||||
|
* transaction announcements to this peer. */
|
||||||
std::chrono::microseconds m_next_inv_send_time GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0};
|
std::chrono::microseconds m_next_inv_send_time GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user