mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Avoid Simplicity header dependency propogation
The problem with including <simplicity/elements/env.h> in interpreter.h is that now everyone who needs to include interpreter.h also needs access to Simplicity's header files too. This commit breaks that dependency chain by using forward declarations. It will pay signifigant dividends when elements switches to CMake.
This commit is contained in:
parent
72b7c4646b
commit
6c7788adf3
2 changed files with 10 additions and 7 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <script/script.h>
|
||||
#include <uint256.h>
|
||||
extern "C" {
|
||||
#include <simplicity/elements/env.h>
|
||||
#include <simplicity/elements/exec.h>
|
||||
#include <simplicity/errorCodes.h>
|
||||
}
|
||||
|
|
@ -2675,6 +2676,10 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
|
|||
}
|
||||
}
|
||||
|
||||
void SimplicityTransactionDeleter::operator()(elementsTransaction* ptr) const {
|
||||
simplicity_elements_freeTransaction(ptr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
|
||||
: PrecomputedTransactionData(uint256{})
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@
|
|||
#include <script/script_error.h>
|
||||
#include <span.h>
|
||||
#include <primitives/transaction.h>
|
||||
extern "C" {
|
||||
#include <simplicity/elements/env.h>
|
||||
}
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
|
@ -169,12 +166,13 @@ enum : uint32_t {
|
|||
|
||||
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
|
||||
|
||||
// Forward declarations of Simplicity structures.
|
||||
struct elementsTransaction;
|
||||
struct rawElementsTapEnv;
|
||||
|
||||
struct SimplicityTransactionDeleter
|
||||
{
|
||||
void operator()(elementsTransaction* ptr)
|
||||
{
|
||||
simplicity_elements_freeTransaction(ptr);
|
||||
}
|
||||
void operator()(elementsTransaction* ptr) const;
|
||||
};
|
||||
using SimplicityTransactionUniquePtr = std::unique_ptr<elementsTransaction, SimplicityTransactionDeleter>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue