| 81 | } |
| 82 | |
| 83 | std::unordered_map<int64_t, int64_t> getOutputDistribution2(Blockchain &chain, int start, int stop) { |
| 84 | auto mapFunc = [](const BlockRange &segment) { |
| 85 | std::unordered_map<int64_t, int64_t> distribution; |
| 86 | for (auto block : segment) { |
| 87 | RANGES_FOR(auto tx, block) { |
| 88 | RANGES_FOR(auto output, tx.outputs()) { |
| 89 | auto value = output.getValue(); |
| 90 | value &= ~0xFF; |
| 91 | auto it = distribution.insert(std::make_pair(value, 0)); |
| 92 | it.first->second++; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | return distribution; |
| 97 | }; |
| 98 | |
| 99 | auto reduceFunc = [] (std::unordered_map<int64_t, int64_t> &map1, std::unordered_map<int64_t, int64_t> &map2) -> std::unordered_map<int64_t, int64_t> & { |
| 100 | for (auto &pair : map2) { |
| 101 | auto res = map1.insert(pair); |
| 102 | if (!res.second) { |
| 103 | res.first->second += pair.second; |
| 104 | } |
| 105 | } |
| 106 | return map1; |
| 107 | }; |
| 108 | |
| 109 | return chain[{start, stop}].mapReduce<std::unordered_map<int64_t, int64_t>>(mapFunc, reduceFunc); |
| 110 | } |
| 111 | |
| 112 | int64_t maxValOutput1(Blockchain &chain, int start, int stop) { |
| 113 | int64_t maxValue = 0; |