MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / operator()

Method operator()

src/process_xthinblock.cpp:13–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13void XThinBlockProcessor::operator()(
14 CDataStream& vRecv, const TxFinder& txfinder,
15 uint64_t currMaxBlockSize, int activeChainHeight)
16{
17 XThinBlock block;
18 vRecv >> block;
19
20 uint256 hash = block.header.GetHash();
21
22 LogPrintf("received xthinblock %s from peer=%d\n",
23 hash.ToString(), worker.nodeID());
24
25 try {
26 block.selfValidate(currMaxBlockSize);
27 }
28 catch (const std::invalid_argument& e) {
29 LogPrint("thin", "Invalid xthin block %s\n", e.what());
30 rejectBlock(hash, e.what(), 20);
31 return;
32 }
33
34 if (requestConnectHeaders(block.header)) {
35 worker.stopWork(hash);
36 return;
37 }
38
39 if (!setToWork(block.header, activeChainHeight))
40 return;
41
42 from.AddInventoryKnown(CInv(MSG_XTHINBLOCK, hash));
43
44 try {
45 XThinStub stub(block);
46 worker.buildStub(stub, txfinder, from);
47 }
48 catch (const thinblock_error& e) {
49 rejectBlock(hash, e.what(), 10);
50 return;
51 }
52
53 if (!worker.isWorkingOn(hash)) {
54 // Stub had enough data to finish
55 // the block.
56 return;
57 }
58
59 // Request missing
60 std::vector<std::pair<int, ThinTx> > missing = worker.getTxsMissing(hash);
61
62 XThinReRequest req;
63 req.block = hash;
64
65 for (auto& t : missing)
66 req.txRequesting.insert(t.second.cheap());
67
68 LogPrintf("re-requesting xthin %d missing transactions for %s from peer=%d\n",
69 missing.size(), hash.ToString(), from.id);
70

Callers

nothing calls this directly

Calls 13

selfValidateMethod · 0.80
AddInventoryKnownMethod · 0.80
isWorkingOnMethod · 0.80
PushMessageMethod · 0.80
CInvClass · 0.70
GetHashMethod · 0.45
ToStringMethod · 0.45
nodeIDMethod · 0.45
stopWorkMethod · 0.45
buildStubMethod · 0.45
getTxsMissingMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected