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

Method requestBlockAnnouncements

src/thinblockmanager.cpp:191–219  ·  view source on GitHub ↗

We ask for announcements with blocks from the last 3 peers to provide a thin block first.

Source from the content-addressed store, hash-verified

189// We ask for announcements with blocks from the
190// last 3 peers to provide a thin block first.
191void ThinBlockManager::requestBlockAnnouncements(ThinBlockWorker& w, CNode& node) {
192
193 typedef std::unique_ptr<BlockAnnHandle> annh;
194 auto it = std::find_if(
195 begin(announcers), end(announcers), [&w](const annh& h) {
196 return w.nodeID() == h->nodeID();
197 });
198
199 if (it != end(announcers)) {
200 // Already receiving announcements from peer.
201 // Move to the front.
202 std::rotate(it, it + 1, end(announcers));
203 return;
204 }
205
206 auto handle = w.requestBlockAnnouncements(node);
207 if (!bool(handle)) {
208 // Peer cannot provide block announcements
209 // with thin blocks.
210 return;
211 }
212
213 announcers.push_back(std::move(handle));
214
215 // Only request thin block announcements from 3 peers at a time.
216 if (announcers.size() > 3)
217 announcers.erase(begin(announcers));
218 LogPrint("ann", "Thin block announcers: %d\n", announcers.size());
219}

Callers

nothing calls this directly

Calls 4

nodeIDMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected