diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -996,6 +996,18 @@ // m_tx_relay == nullptr if we're not relaying transactions with this peer std::unique_ptr m_tx_relay; + struct ProofRelay { + mutable Mutex cs_proof_inventory; + CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_proof_inventory){ + 50000, 0.000001}; + // Set of proof ids we still have to announce. + std::set setInventoryProofsToSend; + std::chrono::microseconds nNextInvSend{0}; + }; + + // m_proof_relay == nullptr if we're not relaying proofs with this peer + std::unique_ptr m_proof_relay; + struct AvalancheState { AvalancheState() {} @@ -1161,6 +1173,23 @@ } } + void AddKnownProof(const avalanche::ProofId &proofid) { + if (m_proof_relay != nullptr) { + LOCK(m_proof_relay->cs_proof_inventory); + m_proof_relay->filterInventoryKnown.insert(proofid); + } + } + + void PushProofInventory(const avalanche::ProofId &proofid) { + if (m_proof_relay == nullptr) { + return; + } + LOCK(m_proof_relay->cs_proof_inventory); + if (!m_proof_relay->filterInventoryKnown.contains(proofid)) { + m_proof_relay->setInventoryProofsToSend.insert(proofid); + } + } + void CloseSocketDisconnect(); void copyStats(CNodeStats &stats, const std::vector &m_asmap); diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -3004,6 +3004,7 @@ hashContinue = BlockHash(); if (conn_type_in != ConnectionType::BLOCK_RELAY) { m_tx_relay = std::make_unique(); + m_proof_relay = std::make_unique(); m_addr_known = std::make_unique(5000, 0.001); }