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

Method CalculateMemPoolAncestors

src/txmempool.cpp:130–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130CTxMemPool::setEntries CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry) const
131{
132 auto ancestors = m_txgraph->GetAncestors(entry, TxGraph::Level::MAIN);
133 setEntries ret;
134 if (ancestors.size() > 0) {
135 for (auto ancestor : ancestors) {
136 if (ancestor != &entry) {
137 ret.insert(mapTx.iterator_to(static_cast<const CTxMemPoolEntry&>(*ancestor)));
138 }
139 }
140 return ret;
141 }
142
143 // If we didn't get anything back, the transaction is not in the graph.
144 // Find each parent and call GetAncestors on each.
145 setEntries staged_parents;
146 const CTransaction &tx = entry.GetTx();
147
148 // Get parents of this transaction that are in the mempool
149 for (unsigned int i = 0; i < tx.vin.size(); i++) {
150 std::optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
151 if (piter) {
152 staged_parents.insert(*piter);
153 }
154 }
155
156 for (const auto& parent : staged_parents) {
157 auto parent_ancestors = m_txgraph->GetAncestors(*parent, TxGraph::Level::MAIN);
158 for (auto ancestor : parent_ancestors) {
159 ret.insert(mapTx.iterator_to(static_cast<const CTxMemPoolEntry&>(*ancestor)));
160 }
161 }
162
163 return ret;
164}
165
166static CTxMemPool::Options&& Flatten(CTxMemPool::Options&& opts, bilingual_str& error)
167{

Callers 4

IsRBFOptInFunction · 0.45
getmempoolancestorsFunction · 0.45

Calls 4

GetAncestorsMethod · 0.80
GetTxMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected