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 <random.h> | #include <random.h> | ||||
#include <cassert> | #include <cassert> | ||||
namespace avalanche { | namespace avalanche { | ||||
PeerId PeerManager::addPeer(PeerId p, uint32_t score) { | PeerId PeerManager::addPeer(PeerId p, uint32_t score) { | ||||
auto inserted = | auto inserted = peers.emplace(p, uint32_t(slots.size()), Proof(score)); | ||||
peers.emplace(p, score, uint32_t(slots.size()), ProofId(GetRandHash())); | |||||
assert(inserted.second); | assert(inserted.second); | ||||
const uint64_t start = slotCount; | const uint64_t start = slotCount; | ||||
slots.emplace_back(start, score, p); | slots.emplace_back(start, score, p); | ||||
slotCount = start + score; | slotCount = start + score; | ||||
return p; | return p; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |