refactor(miniscript): Remove Node::subs mutability
This commit is contained in:
2 files changed
+4
-4
No files matched your search
@@ -2566,7 +2566,7 @@ std::vector<std::unique_ptr<DescriptorImpl>> ParseScript(uint32_t& key_exp_index
|
|||||||
}
|
}
|
||||||
if (!node->IsSane() || node->IsNotSatisfiable()) {
|
if (!node->IsSane() || node->IsNotSatisfiable()) {
|
||||||
// Try to find the first insane sub for better error reporting.
|
// Try to find the first insane sub for better error reporting.
|
||||||
auto insane_node = node.get();
|
const decltype(node)::element_type* insane_node = node.get();
|
||||||
if (const auto sub = node->FindInsaneSub()) insane_node = sub;
|
if (const auto sub = node->FindInsaneSub()) insane_node = sub;
|
||||||
error = *insane_node->ToString(parser);
|
error = *insane_node->ToString(parser);
|
||||||
if (!insane_node->IsValid()) {
|
if (!insane_node->IsValid()) {
|
||||||
|
|||||||
@@ -191,11 +191,11 @@ inline consteval Type operator""_mst(const char* c, size_t l)
|
|||||||
using Opcode = std::pair<opcodetype, std::vector<unsigned char>>;
|
using Opcode = std::pair<opcodetype, std::vector<unsigned char>>;
|
||||||
|
|
||||||
template<typename Key> class Node;
|
template<typename Key> class Node;
|
||||||
template<typename Key> using NodeRef = std::unique_ptr<const Node<Key>>;
|
template<typename Key> using NodeRef = std::unique_ptr<Node<Key>>;
|
||||||
|
|
||||||
//! Construct a miniscript node as a unique_ptr.
|
//! Construct a miniscript node as a unique_ptr.
|
||||||
template<typename Key, typename... Args>
|
template<typename Key, typename... Args>
|
||||||
NodeRef<Key> MakeNodeRef(Args&&... args) { return std::make_unique<const Node<Key>>(std::forward<Args>(args)...); }
|
NodeRef<Key> MakeNodeRef(Args&&... args) { return std::make_unique<Node<Key>>(std::forward<Args>(args)...); }
|
||||||
|
|
||||||
//! Unordered traversal of a miniscript node tree.
|
//! Unordered traversal of a miniscript node tree.
|
||||||
template <typename Key, std::invocable<const Node<Key>&> Fn>
|
template <typename Key, std::invocable<const Node<Key>&> Fn>
|
||||||
@@ -545,7 +545,7 @@ class Node
|
|||||||
//! The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD160).
|
//! The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD160).
|
||||||
std::vector<unsigned char> data;
|
std::vector<unsigned char> data;
|
||||||
//! Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH)
|
//! Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH)
|
||||||
mutable std::vector<NodeRef<Key>> subs;
|
std::vector<NodeRef<Key>> subs;
|
||||||
//! The Script context for this node. Either P2WSH or Tapscript.
|
//! The Script context for this node. Either P2WSH or Tapscript.
|
||||||
MiniscriptContext m_script_ctx;
|
MiniscriptContext m_script_ctx;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user