mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
[REFACTOR] Initialize PrecomputedTransactionData in CheckInputScripts
Add a default constructor to `PrecomputedTransactionData`, which doesn't initialize the struct's members. Instead they're initialized inside the `CheckInputScripts()` function. This allows a later commit to add the spent UTXOs to that structure.
This commit is contained in:
parent
5504703a9f
commit
f63dec189c
3 changed files with 32 additions and 9 deletions
|
|
@ -1279,18 +1279,29 @@ uint256 GetOutputsHash(const T& txTo)
|
|||
} // namespace
|
||||
|
||||
template <class T>
|
||||
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
|
||||
void PrecomputedTransactionData::Init(const T& txTo)
|
||||
{
|
||||
assert(!m_ready);
|
||||
|
||||
// Cache is calculated only for transactions with witness
|
||||
if (txTo.HasWitness()) {
|
||||
hashPrevouts = GetPrevoutHash(txTo);
|
||||
hashSequence = GetSequenceHash(txTo);
|
||||
hashOutputs = GetOutputsHash(txTo);
|
||||
ready = true;
|
||||
}
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
|
||||
{
|
||||
Init(txTo);
|
||||
}
|
||||
|
||||
// explicit instantiation
|
||||
template void PrecomputedTransactionData::Init(const CTransaction& txTo);
|
||||
template void PrecomputedTransactionData::Init(const CMutableTransaction& txTo);
|
||||
template PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo);
|
||||
template PrecomputedTransactionData::PrecomputedTransactionData(const CMutableTransaction& txTo);
|
||||
|
||||
|
|
@ -1303,7 +1314,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
|
|||
uint256 hashPrevouts;
|
||||
uint256 hashSequence;
|
||||
uint256 hashOutputs;
|
||||
const bool cacheready = cache && cache->ready;
|
||||
const bool cacheready = cache && cache->m_ready;
|
||||
|
||||
if (!(nHashType & SIGHASH_ANYONECANPAY)) {
|
||||
hashPrevouts = cacheready ? cache->hashPrevouts : GetPrevoutHash(txTo);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue