Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | auto registerVoteItems = [&](auto voteRecordsWriteView, auto &updates, | ||||
auto it = voteRecordsWriteView->find(item); | auto it = voteRecordsWriteView->find(item); | ||||
if (it == voteRecordsWriteView.end()) { | if (it == voteRecordsWriteView.end()) { | ||||
// We are not voting on that item anymore. | // We are not voting on that item anymore. | ||||
continue; | continue; | ||||
} | } | ||||
auto &vr = it->second; | auto &vr = it->second; | ||||
if (!vr.registerVote(nodeid, v.GetError())) { | if (!vr.registerVote(nodeid, v.GetError())) { | ||||
if (vr.isStale()) { | |||||
// Just drop stale votes. If we see this item again, we'll | |||||
// do a new vote. | |||||
updates.emplace_back(item, VoteStatus::Stale); | |||||
voteRecordsWriteView->erase(it); | |||||
} | |||||
// This vote did not provide any extra information, move on. | // This vote did not provide any extra information, move on. | ||||
continue; | continue; | ||||
} | } | ||||
if (!vr.hasFinalized()) { | if (!vr.hasFinalized()) { | ||||
// This item has note been finalized, so we have nothing more to | // This item has note been finalized, so we have nothing more to | ||||
// do. | // do. | ||||
updates.emplace_back(item, vr.isAccepted() | updates.emplace_back(item, vr.isAccepted() | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | auto extractVoteRecordsToInvs = [&](const auto &itemVoteRecordRange, | ||||
auto buildInvFromVoteItem) { | auto buildInvFromVoteItem) { | ||||
for (const auto &[item, voteRecord] : itemVoteRecordRange) { | for (const auto &[item, voteRecord] : itemVoteRecordRange) { | ||||
if (invs.size() >= AVALANCHE_MAX_ELEMENT_POLL) { | if (invs.size() >= AVALANCHE_MAX_ELEMENT_POLL) { | ||||
// Make sure we do not produce more invs than specified by the | // Make sure we do not produce more invs than specified by the | ||||
// protocol. | // protocol. | ||||
return true; | return true; | ||||
} | } | ||||
const bool shouldPoll = | const bool shouldPoll = voteRecord.shouldPoll() && | ||||
Fabien: What does it solve ? | |||||
sdulfariAuthorUnsubmitted Done Inline ActionsLooking at VoteRecord's API, you would expect shouldPoll() would always be called, not that it's a special test-only function. Since I want that logic to be changed, it makes sense that this logic applies to all code paths. Otherwise, it's possible to pass unit tests when infact the entire thing is broken in production. sdulfari: Looking at VoteRecord's API, you would expect shouldPoll() would always be called, not that… | |||||
forPoll ? voteRecord.registerPoll() : voteRecord.shouldPoll(); | (!forPoll || voteRecord.registerPoll()); | ||||
if (!shouldPoll) { | if (!shouldPoll) { | ||||
continue; | continue; | ||||
} | } | ||||
invs.emplace_back(buildInvFromVoteItem(item)); | invs.emplace_back(buildInvFromVoteItem(item)); | ||||
} | } | ||||
return invs.size() >= AVALANCHE_MAX_ELEMENT_POLL; | return invs.size() >= AVALANCHE_MAX_ELEMENT_POLL; | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |
What does it solve ?