Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofpool.cpp
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | ProofPool::getRegistrationTime(const ProofId &proofid) const { | ||||
auto it = registrationTimes.find(proofid); | auto it = registrationTimes.find(proofid); | ||||
if (it == registrationTimes.end()) { | if (it == registrationTimes.end()) { | ||||
return {}; | return {}; | ||||
} | } | ||||
return std::make_optional(it->registrationTime); | return std::make_optional(it->registrationTime); | ||||
} | } | ||||
void ProofPool::removeObsoleteProofs(std::chrono::seconds cutoffTime) { | |||||
auto &timeView = registrationTimes.get<by_registration_time>(); | |||||
auto &poolView = pool.get<by_proofid>(); | |||||
auto lowerBound = timeView.lower_bound(cutoffTime.count()); | |||||
for (auto it = timeView.begin(); it != lowerBound; it++) { | |||||
poolView.erase(it->proofid); | |||||
} | |||||
timeView.erase(timeView.begin(), timeView.lower_bound(cutoffTime.count())); | |||||
} | |||||
} // namespace avalanche | } // namespace avalanche |