Remove a random orphan block (which does not have any dependent orphans).
| 371 | |
| 372 | // Remove a random orphan block (which does not have any dependent orphans). |
| 373 | bool static PruneOrphanBlocks(int32_t height) { |
| 374 | if (mapOrphanBlocksByPrev.size() <= MAX_ORPHAN_BLOCKS) { |
| 375 | return true; |
| 376 | } |
| 377 | |
| 378 | COrphanBlock *pOrphanBlock = *setOrphanBlock.rbegin(); |
| 379 | if (pOrphanBlock->height <= height) { |
| 380 | return false; |
| 381 | } |
| 382 | uint256 hash = pOrphanBlock->blockHash; |
| 383 | uint256 prevHash = pOrphanBlock->prevBlockHash; |
| 384 | setOrphanBlock.erase(pOrphanBlock); |
| 385 | multimap<uint256, COrphanBlock *>::iterator beg = mapOrphanBlocksByPrev.lower_bound(prevHash); |
| 386 | multimap<uint256, COrphanBlock *>::iterator end = mapOrphanBlocksByPrev.upper_bound(prevHash); |
| 387 | while (beg != end) { |
| 388 | if (beg->second->blockHash == hash) { |
| 389 | mapOrphanBlocksByPrev.erase(beg); |
| 390 | break; |
| 391 | } |
| 392 | ++beg; |
| 393 | } |
| 394 | mapOrphanBlocks.erase(hash); |
| 395 | delete pOrphanBlock; |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | bool fLargeWorkForkFound = false; |
| 400 | bool fLargeWorkInvalidChainFound = false; |
no test coverage detected