| 115 | } |
| 116 | |
| 117 | Chunks buildNextLevel(Chunks& _currentLevel) |
| 118 | { |
| 119 | size_t const maxChildNum = 174; |
| 120 | |
| 121 | Chunks nextLevel; |
| 122 | Chunks links; |
| 123 | |
| 124 | for (Chunk& chunk: _currentLevel) |
| 125 | { |
| 126 | links.emplace_back(std::move(chunk.hash), chunk.size, chunk.blockSize); |
| 127 | if (links.size() == maxChildNum) |
| 128 | { |
| 129 | nextLevel.emplace_back(combineLinks(links)); |
| 130 | links = {}; |
| 131 | } |
| 132 | } |
| 133 | if (!links.empty()) |
| 134 | nextLevel.emplace_back(combineLinks(links)); |
| 135 | |
| 136 | return nextLevel; |
| 137 | } |
| 138 | |
| 139 | /// Builds a tree starting from the bottom level where nodes are data nodes. |
| 140 | /// Data nodes should be calculated and passed as the only level in chunk levels |
no test coverage detected