| 11 | |
| 12 | |
| 13 | void 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 |
nothing calls this directly
no test coverage detected