| 197 | //! Unordered traversal of a miniscript node tree. |
| 198 | template <typename Key, std::invocable<const Node<Key>&> Fn> |
| 199 | void ForEachNode(const Node<Key>& root, Fn&& fn) |
| 200 | { |
| 201 | std::vector<std::reference_wrapper<const Node<Key>>> stack{root}; |
| 202 | while (!stack.empty()) { |
| 203 | const Node<Key>& node = stack.back(); |
| 204 | std::invoke(fn, node); |
| 205 | stack.pop_back(); |
| 206 | for (const auto& sub : node.Subs()) { |
| 207 | stack.emplace_back(sub); |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | //! The different node types in miniscript. |
| 213 | enum class Fragment { |
no test coverage detected