Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | bool Processor::registerVotes(NodeId nodeid, const Response &response, | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
{ | { | ||||
// Check that the query exists. | // Check that the query exists. | ||||
auto w = queries.getWriteView(); | auto w = queries.getWriteView(); | ||||
auto it = w->find(std::make_tuple(nodeid, response.getRound())); | auto it = w->find(std::make_tuple(nodeid, response.getRound())); | ||||
if (it == w.end()) { | if (it == w.end()) { | ||||
LOCK(cs_main); | |||||
Misbehaving(nodeid, 2, "unexpcted-ava-response"); | Misbehaving(nodeid, 2, "unexpcted-ava-response"); | ||||
return false; | return false; | ||||
} | } | ||||
invs = std::move(it->invs); | invs = std::move(it->invs); | ||||
w->erase(it); | w->erase(it); | ||||
} | } | ||||
// Verify that the request and the vote are consistent. | // Verify that the request and the vote are consistent. | ||||
const std::vector<Vote> &votes = response.GetVotes(); | const std::vector<Vote> &votes = response.GetVotes(); | ||||
size_t size = invs.size(); | size_t size = invs.size(); | ||||
if (votes.size() != size) { | if (votes.size() != size) { | ||||
LOCK(cs_main); | |||||
Misbehaving(nodeid, 100, "invalid-ava-response-size"); | Misbehaving(nodeid, 100, "invalid-ava-response-size"); | ||||
return false; | return false; | ||||
} | } | ||||
for (size_t i = 0; i < size; i++) { | for (size_t i = 0; i < size; i++) { | ||||
if (invs[i].hash != votes[i].GetHash()) { | if (invs[i].hash != votes[i].GetHash()) { | ||||
LOCK(cs_main); | |||||
Misbehaving(nodeid, 100, "invalid-ava-response-content"); | Misbehaving(nodeid, 100, "invalid-ava-response-content"); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
std::map<CBlockIndex *, Vote> responseIndex; | std::map<CBlockIndex *, Vote> responseIndex; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |