Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 972 Lines • ▼ Show 20 Lines | struct TxRelay { | ||||
GUARDED_BY(cs_filter){nullptr}; | GUARDED_BY(cs_filter){nullptr}; | ||||
mutable RecursiveMutex cs_tx_inventory; | mutable RecursiveMutex cs_tx_inventory; | ||||
CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_tx_inventory){ | CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_tx_inventory){ | ||||
50000, 0.000001}; | 50000, 0.000001}; | ||||
// Set of transaction ids we still have to announce. | // Set of transaction ids we still have to announce. | ||||
// They are sorted by the mempool before relay, so the order is not | // They are sorted by the mempool before relay, so the order is not | ||||
// important. | // important. | ||||
std::set<TxId> setInventoryTxToSend; | std::set<TxId> setInventoryTxToSend; | ||||
deadalnix: GUARDED_BY(cs_tx_inventory)
No? | |||||
// Used for BIP35 mempool sending | // Used for BIP35 mempool sending | ||||
bool fSendMempool GUARDED_BY(cs_tx_inventory){false}; | bool fSendMempool GUARDED_BY(cs_tx_inventory){false}; | ||||
// Last time a "MEMPOOL" request was serviced. | // Last time a "MEMPOOL" request was serviced. | ||||
std::atomic<std::chrono::seconds> m_last_mempool_req{ | std::atomic<std::chrono::seconds> m_last_mempool_req{ | ||||
std::chrono::seconds{0}}; | std::chrono::seconds{0}}; | ||||
std::chrono::microseconds nNextInvSend{0}; | std::chrono::microseconds nNextInvSend{0}; | ||||
RecursiveMutex cs_feeFilter; | RecursiveMutex cs_feeFilter; | ||||
// Minimum fee rate with which to filter inv's to this node | // Minimum fee rate with which to filter inv's to this node | ||||
Amount minFeeFilter GUARDED_BY(cs_feeFilter){Amount::zero()}; | Amount minFeeFilter GUARDED_BY(cs_feeFilter){Amount::zero()}; | ||||
Amount lastSentFeeFilter{Amount::zero()}; | Amount lastSentFeeFilter{Amount::zero()}; | ||||
int64_t nextSendTimeFeeFilter{0}; | int64_t nextSendTimeFeeFilter{0}; | ||||
}; | }; | ||||
// m_tx_relay == nullptr if we're not relaying transactions with this peer | // m_tx_relay == nullptr if we're not relaying transactions with this peer | ||||
std::unique_ptr<TxRelay> m_tx_relay; | std::unique_ptr<TxRelay> m_tx_relay; | ||||
struct ProofRelay { | struct ProofRelay { | ||||
mutable RecursiveMutex cs_proof_inventory; | mutable RecursiveMutex cs_proof_inventory; | ||||
// Prevent sending proof invs if the peer already knows about them | |||||
CRollingBloomFilter filterProofKnown GUARDED_BY(cs_proof_inventory){ | |||||
10000, 0.000001}; | |||||
std::set<avalanche::ProofId> | std::set<avalanche::ProofId> | ||||
setInventoryProofToSend GUARDED_BY(cs_proof_inventory); | setInventoryProofToSend GUARDED_BY(cs_proof_inventory); | ||||
}; | }; | ||||
// m_proof_relay == nullptr if we're not relaying proofs with this peer | // m_proof_relay == nullptr if we're not relaying proofs with this peer | ||||
std::unique_ptr<ProofRelay> m_proof_relay; | std::unique_ptr<ProofRelay> m_proof_relay; | ||||
struct AvalancheState { | struct AvalancheState { | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | void PushTxInventory(const TxId &txid) { | ||||
return; | return; | ||||
} | } | ||||
LOCK(m_tx_relay->cs_tx_inventory); | LOCK(m_tx_relay->cs_tx_inventory); | ||||
if (!m_tx_relay->filterInventoryKnown.contains(txid)) { | if (!m_tx_relay->filterInventoryKnown.contains(txid)) { | ||||
m_tx_relay->setInventoryTxToSend.insert(txid); | m_tx_relay->setInventoryTxToSend.insert(txid); | ||||
} | } | ||||
} | } | ||||
void AddKnownProof(const avalanche::ProofId &proofid) { | |||||
if (m_proof_relay != nullptr) { | |||||
WITH_LOCK(m_proof_relay->cs_proof_inventory, | |||||
m_proof_relay->filterProofKnown.insert(proofid)); | |||||
deadalnixUnsubmitted Not Done Inline ActionsI'm nto sure this WITH8LOCK construct really is more readable than the alternative, but it's okay either way. deadalnix: I'm nto sure this WITH8LOCK construct really is more readable than the alternative, but it's… | |||||
} | |||||
} | |||||
void PushProofInventory(const avalanche::ProofId &proofid) { | void PushProofInventory(const avalanche::ProofId &proofid) { | ||||
if (m_proof_relay == nullptr) { | if (m_proof_relay == nullptr) { | ||||
m_proof_relay = std::make_unique<ProofRelay>(); | m_proof_relay = std::make_unique<ProofRelay>(); | ||||
} | } | ||||
WITH_LOCK(m_proof_relay->cs_proof_inventory, | LOCK(m_proof_relay->cs_proof_inventory); | ||||
m_proof_relay->setInventoryProofToSend.insert(proofid)); | if (!m_proof_relay->filterProofKnown.contains(proofid)) { | ||||
m_proof_relay->setInventoryProofToSend.insert(proofid); | |||||
} | |||||
} | } | ||||
void CloseSocketDisconnect(); | void CloseSocketDisconnect(); | ||||
void copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap); | void copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap); | ||||
ServiceFlags GetLocalServices() const { return nLocalServices; } | ServiceFlags GetLocalServices() const { return nLocalServices; } | ||||
Show All 23 Lines |
No?