MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / pickDownloadStrategy

Method pickDownloadStrategy

src/blockannounce.cpp:51–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50
51BlockAnnounceReceiver::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
92void requestHeaders(CNode& from, const uint256& block) {
93

Callers

nothing calls this directly

Calls 6

OptClass · 0.85
AvoidFullBlocksMethod · 0.80
numWorkersMethod · 0.80
ThinBlocksMaxParallelMethod · 0.80
isInFlightMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected