Commit 320af025 authored by Adam P. Goucher's avatar Adam P. Goucher

Refine difficulty estimates using blockchain

parent 66dafe2f
......@@ -3,6 +3,8 @@
#include <sstream>
#include <fstream>
#include <iostream>
#include <utility>
#include <set>
/*
* This contains everything necessary for performing a soup search.
......@@ -66,6 +68,32 @@ public:
}
void set_difficulties(std::string standard, std::map<std::string, int64_t> &occ) {
/*
* Update difficulty estimates based upon initial segment of blockchain
* objects. This only affects the difficulties of objects in such a way
* that it cannot invalidate existing blocks.
*/
std::set<std::pair<int64_t, std::string> > nocc;
int64_t totobj = 0;
for (auto it = occ.begin(); it != occ.end(); ++it) {
if (get_difficulty(it->first) > difficulties[standard]) {
nocc.emplace(it->second, it->first);
totobj += it->second;
}
}
totobj += occ[standard];
int64_t cumobj = 0;
for (auto it = nocc.begin(); it != nocc.end(); ++it) {
cumobj += it->first;
difficulties[it->second] = (difficulties[standard] * totobj) / cumobj;
}
}
int64_t separate(UPATTERN &pat, int duration, bool proceedNonetheless, apg::base_classifier<BITPLANES> &cfier, std::string suffix) {
pat.decache();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment