Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <avalanche/peermanager.h> | #include <avalanche/peermanager.h> | ||||
#include <avalanche/delegation.h> | #include <avalanche/delegation.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <net_processing.h> // For RelayProof | |||||
#include <random.h> | #include <random.h> | ||||
#include <validation.h> // For ChainstateActive() | #include <validation.h> // For ChainstateActive() | ||||
#include <cassert> | #include <cassert> | ||||
namespace avalanche { | namespace avalanche { | ||||
bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { | bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { | ||||
▲ Show 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | if (getProof(proofid)) { | ||||
m_unbroadcast_proofids.insert(proofid); | m_unbroadcast_proofids.insert(proofid); | ||||
} | } | ||||
} | } | ||||
void PeerManager::removeUnbroadcastProof(const ProofId &proofid) { | void PeerManager::removeUnbroadcastProof(const ProofId &proofid) { | ||||
m_unbroadcast_proofids.erase(proofid); | m_unbroadcast_proofids.erase(proofid); | ||||
} | } | ||||
void PeerManager::broadcastProofs(const CConnman &connman) { | |||||
// For some reason SaltedProofIdHasher prevents the set from being swappable | |||||
auto previous_unbroadcasted_proofids = std::move(m_unbroadcast_proofids); | |||||
m_unbroadcast_proofids.clear(); | |||||
for (auto &proofid : previous_unbroadcasted_proofids) { | |||||
if (getProof(proofid)) { | |||||
m_unbroadcast_proofids.insert(proofid); | |||||
RelayProof(proofid, connman); | |||||
} | |||||
} | |||||
} | |||||
} // namespace avalanche | } // namespace avalanche |