| 49 | |
| 50 | |
| 51 | BlockAnnounceReceiver::DownloadStrategy BlockAnnounceReceiver::pickDownloadStrategy() { |
| 52 | |
| 53 | |
| 54 | if (!almostSynced()) |
| 55 | return DONT_DOWNL; |
| 56 | |
| 57 | if (hasBlockData()) |
| 58 | return DONT_DOWNL; |
| 59 | |
| 60 | if (!fetchAsThin()) { |
| 61 | |
| 62 | if (blocksInFlight.isInFlight(block)) |
| 63 | return DONT_DOWNL; |
| 64 | |
| 65 | NodeStatePtr nodestate(from.id); |
| 66 | if (nodestate->nBlocksInFlight >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) |
| 67 | return DONT_DOWNL; |
| 68 | |
| 69 | if (Opt().AvoidFullBlocks()) { |
| 70 | LogPrint("thin", "avoiding full blocks, not requesting %s from %d\n", |
| 71 | block.ToString(), from.id); |
| 72 | |
| 73 | return DONT_DOWNL; |
| 74 | } |
| 75 | |
| 76 | return DOWNL_FULL_NOW; |
| 77 | } |
| 78 | |
| 79 | // At this point we know we want a thin block. |
| 80 | |
| 81 | NodeStatePtr state(from.id); |
| 82 | |
| 83 | if (thinmg.numWorkers(block) >= Opt().ThinBlocksMaxParallel()) { |
| 84 | LogPrint("thin", "max parallel thin req reached, not req %s from peer %d\n", |
| 85 | block.ToString(), from.id); |
| 86 | return DONT_DOWNL; |
| 87 | } |
| 88 | |
| 89 | return DOWNL_THIN_NOW; |
| 90 | } |
| 91 | |
| 92 | void requestHeaders(CNode& from, const uint256& block) { |
| 93 |
nothing calls this directly
no test coverage detected