MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IsChildWithParents

Function IsChildWithParents

src/policy/packages.cpp:119–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool IsChildWithParents(const Package& package)
120{
121 assert(std::all_of(package.cbegin(), package.cend(), [](const auto& tx){return tx != nullptr;}));
122 if (package.size() < 2) return false;
123
124 // The package is expected to be sorted, so the last transaction is the child.
125 const auto& child = package.back();
126 std::unordered_set<Txid, SaltedTxidHasher> input_txids;
127 std::transform(child->vin.cbegin(), child->vin.cend(),
128 std::inserter(input_txids, input_txids.end()),
129 [](const auto& input) { return input.prevout.hash; });
130
131 // Every transaction must be a parent of the last transaction in the package.
132 return std::all_of(package.cbegin(), package.cend() - 1,
133 [&input_txids](const auto& ptx) { return input_txids.contains(ptx->GetHash()); });
134}
135
136bool IsChildWithParentsTree(const Package& package)
137{

Callers 5

PackageRBFChecksMethod · 0.85
AcceptPackageMethod · 0.85
IsChildWithParentsTreeFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
CheckPackageToValidateFunction · 0.85

Calls 7

cbeginMethod · 0.45
cendMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45
endMethod · 0.45
containsMethod · 0.45
GetHashMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
CheckPackageToValidateFunction · 0.68