| 162 | } |
| 163 | |
| 164 | void ThinBlockManager::finishBlock(const uint256& h, ThinBlockBuilder& builder) { |
| 165 | CBlock block; |
| 166 | try { |
| 167 | block = builder.finishBlock(); |
| 168 | } |
| 169 | catch (thinblock_error& e) { |
| 170 | LogPrintf("ERROR: a thinblock builder failed to finish block %s - %s\n", |
| 171 | block.ToString(), e.what()); |
| 172 | |
| 173 | // Give up on block |
| 174 | removeIfExists(h); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | typedef std::set<ThinBlockWorker*>::iterator auto_; |
| 179 | std::vector<NodeId> peers; |
| 180 | std::set<ThinBlockWorker*> workers = builders[h].workers; |
| 181 | for (auto_ w = workers.begin(); w != workers.end(); ++w) |
| 182 | peers.push_back((*w)->nodeID()); |
| 183 | |
| 184 | ThinBlockFinishedCallb& callb = *finishedCallb; |
| 185 | callb(block, peers); |
| 186 | removeIfExists(h); |
| 187 | } |
| 188 | |
| 189 | // We ask for announcements with blocks from the |
| 190 | // last 3 peers to provide a thin block first. |