Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.cpp
Show First 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | std::map<CBlockIndex *, AvalancheVote> responseIndex; | ||||
: AvalancheBlockUpdate::Status::Invalid); | : AvalancheBlockUpdate::Status::Invalid); | ||||
w->erase(it); | w->erase(it); | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool AvalancheProcessor::addPeer(NodeId nodeid, int64_t score) { | bool AvalancheProcessor::addPeer(NodeId nodeid, int64_t score, CPubKey pubkey) { | ||||
return peerSet.getWriteView() | return peerSet.getWriteView() | ||||
->insert({nodeid, score, std::chrono::steady_clock::now()}) | ->insert({nodeid, score, std::chrono::steady_clock::now(), | ||||
std::move(pubkey)}) | |||||
.second; | .second; | ||||
} | } | ||||
CPubKey AvalancheProcessor::getPubKey(NodeId nodeid) const { | |||||
auto r = peerSet.getReadView(); | |||||
auto it = r->find(nodeid); | |||||
if (it == r->end()) { | |||||
return CPubKey(); | |||||
} | |||||
return it->pubkey; | |||||
} | |||||
bool AvalancheProcessor::startEventLoop(CScheduler &scheduler) { | bool AvalancheProcessor::startEventLoop(CScheduler &scheduler) { | ||||
LOCK(cs_running); | LOCK(cs_running); | ||||
if (running) { | if (running) { | ||||
// Do not start the event loop twice. | // Do not start the event loop twice. | ||||
return false; | return false; | ||||
} | } | ||||
running = true; | running = true; | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |