| 44 | } |
| 45 | |
| 46 | void XThinBlock::selfValidate(uint64_t currMaxBlockSize) const { |
| 47 | |
| 48 | if (header.GetHash().IsNull()) |
| 49 | throw std::invalid_argument("xthinblock is Null"); |
| 50 | |
| 51 | if (missing.size() == 0) |
| 52 | throw std::invalid_argument("xthinblock is missing coinbase"); |
| 53 | |
| 54 | if (missing.size() > txHashes.size()) |
| 55 | throw std::invalid_argument("xthinblock cannot provide more transactions" |
| 56 | " than it claims are in block"); |
| 57 | |
| 58 | validateNumTxs(txHashes.size(), currMaxBlockSize); |
| 59 | |
| 60 | typedef std::vector<uint64_t>::const_iterator auto_; |
| 61 | std::vector<uint64_t> copy; |
| 62 | for (auto_ t = txHashes.begin(); t != txHashes.end(); ++t) |
| 63 | { |
| 64 | if (isCollision(copy, *t)) |
| 65 | throw std::invalid_argument("hash collision in thin block"); |
| 66 | copy.push_back(*t); |
| 67 | } |
| 68 | |
| 69 | typedef std::vector<CTransaction>::const_iterator auto__; |
| 70 | for (auto__ t = missing.begin(); t != missing.end(); ++t) { |
| 71 | auto_ found = std::find(txHashes.begin(), txHashes.end(), t->GetHash().GetCheapHash()); |
| 72 | if (found != txHashes.end()) |
| 73 | continue; |
| 74 | |
| 75 | throw std::invalid_argument("missing transaction provided " |
| 76 | " was not listed as belonging to block"); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Filter where we tell the node we're requesting a thin block |
| 81 | // from what transactions *not* to include. |