MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsChildWithParents

Function IsChildWithParents

src/policy/packages.cpp:64–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool IsChildWithParents(const Package& package)
65{
66 assert(std::all_of(package.cbegin(), package.cend(), [](const auto& tx){return tx != nullptr;}));
67 if (package.size() < 2) return false;
68
69 // The package is expected to be sorted, so the last transaction is the child.
70 const auto& child = package.back();
71 std::unordered_set<uint256, SaltedTxidHasher> input_txids;
72 std::transform(child->vin.cbegin(), child->vin.cend(),
73 std::inserter(input_txids, input_txids.end()),
74 [](const auto& input) { return input.prevout.hash; });
75
76 // Every transaction must be a parent of the last transaction in the package.
77 return std::all_of(package.cbegin(), package.cend() - 1,
78 [&input_txids](const auto& ptx) { return input_txids.count(ptx->GetHash()) > 0; });
79}

Callers 2

AcceptPackageMethod · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85

Calls 6

cbeginMethod · 0.80
cendMethod · 0.80
countMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
GetHashMethod · 0.45

Tested by 1

BOOST_FIXTURE_TEST_CASEFunction · 0.68