| 128 | } |
| 129 | |
| 130 | CTxMemPool::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 | |
| 166 | static CTxMemPool::Options&& Flatten(CTxMemPool::Options&& opts, bilingual_str& error) |
| 167 | { |
no test coverage detected