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

Method selfValidate

src/xthin.cpp:46–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void 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.

Callers 2

operator()Method · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 9

validateNumTxsFunction · 0.85
isCollisionFunction · 0.85
GetCheapHashMethod · 0.80
IsNullMethod · 0.45
GetHashMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64