mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 21:59:10 +02:00
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:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user