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> | ||||
void PeerManager::addPeer(uint64_t score) { | void PeerManager::addPeer(uint32_t score) { | ||||
const uint64_t start = slotCount; | const uint64_t start = slotCount; | ||||
slots.emplace_back(start, score); | slots.emplace_back(start, score); | ||||
slotCount = start + score; | slotCount = start + score; | ||||
} | } | ||||
void PeerManager::rescorePeer(size_t i, uint64_t score) { | void PeerManager::rescorePeer(size_t i, uint32_t score) { | ||||
assert(i < slots.size()); | assert(i < slots.size()); | ||||
const uint64_t start = slots[i].getStart(); | const uint64_t start = slots[i].getStart(); | ||||
// If this is the last element, we can extend/shrink easily. | // If this is the last element, we can extend/shrink easily. | ||||
if (i + 1 == slots.size()) { | if (i + 1 == slots.size()) { | ||||
slots[i] = slots[i].withScore(score); | slots[i] = slots[i].withScore(score); | ||||
slotCount = slots[i].getStop(); | slotCount = slots[i].getStop(); | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |