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/avalanche.h> | #include <avalanche/avalanche.h> | ||||
#include <avalanche/delegation.h> | #include <avalanche/delegation.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <scheduler.h> | |||||
#include <validation.h> // For ChainstateActive() | #include <validation.h> // For ChainstateActive() | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cassert> | #include <cassert> | ||||
namespace avalanche { | namespace avalanche { | ||||
PeerManager::PeerManager(CScheduler &scheduler) { | |||||
scheduler.scheduleEvery( | |||||
[this]() -> bool { | |||||
this->cleanupDanglingProofs(); | |||||
return true; | |||||
}, | |||||
5min); | |||||
} | |||||
bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { | bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { | ||||
auto &pview = peers.get<by_proofid>(); | auto &pview = peers.get<by_proofid>(); | ||||
auto it = pview.find(proofid); | auto it = pview.find(proofid); | ||||
if (it == pview.end()) { | if (it == pview.end()) { | ||||
// If the node exists, it is actually updating its proof to an unknown | // If the node exists, it is actually updating its proof to an unknown | ||||
// one. In this case we need to remove it so it is not both active and | // one. In this case we need to remove it so it is not both active and | ||||
// pending at the same time. | // pending at the same time. | ||||
▲ Show 20 Lines • Show All 782 Lines • Show Last 20 Lines |