refactor: Add LIFETIMEBOUND to all (w)txid getters

Then, use the compiler warnings to create copies only where needed.

Also, fix iwyu includes while touching the includes.
This commit is contained in:
MarcoFalke
2023-10-27 12:38:21 +02:00
parent e789b30b25
commit faec889f93
6 changed files with 19 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
#ifndef BITCOIN_UTIL_TRANSACTION_IDENTIFIER_H
#define BITCOIN_UTIL_TRANSACTION_IDENTIFIER_H
#include <attributes.h>
#include <uint256.h>
#include <util/types.h>
@@ -35,7 +36,7 @@ public:
template <typename Other>
bool operator<(const Other& other) const { return Compare(other) < 0; }
uint256 ToUint256() const { return m_wrapped; }
const uint256& ToUint256() const LIFETIMEBOUND { return m_wrapped; }
static transaction_identifier FromUint256(const uint256& id) { return {id}; }
/** Wrapped `uint256` methods. */
@@ -56,7 +57,7 @@ public:
* TODO: This should be removed once the majority of the code has switched
* to using the Txid and Wtxid types. Until then it makes for a smoother
* transition to allow this conversion. */
operator uint256() const { return m_wrapped; }
operator const uint256&() const LIFETIMEBOUND { return m_wrapped; }
};
/** Txid commits to all transaction fields except the witness. */