diff options
author | fanquake <fanquake@gmail.com> | 2023-10-29 10:05:13 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-10-29 10:10:53 +0100 |
commit | 42b0d5f59b868e8ed5ae6c7df3bc133f79e3bfb3 (patch) | |
tree | bd32913df89db000f46022e311540dffbdbea257 /src/util/transaction_identifier.h | |
parent | e789b30b2565c8bdbf48a45f2c5a7b92e5d61d25 (diff) | |
parent | faec889f938f90e0b887426db27a15ec0d169399 (diff) | |
download | bitcoin-42b0d5f59b868e8ed5ae6c7df3bc133f79e3bfb3.tar.xz |
Merge bitcoin/bitcoin#28740: refactor: Add LIFETIMEBOUND to all (w)txid getters
faec889f938f90e0b887426db27a15ec0d169399 refactor: Add LIFETIMEBOUND to all (w)txid getters (MarcoFalke)
Pull request description:
Currently some getters return a reference, some don't. Fix this by returning a reference everywhere. Also, add `LIFETIMEBOUND` to all. Then, use the compiler warnings to create copies only where needed.
Also, fix iwyu includes while touching the includes.
ACKs for top commit:
dergoegge:
Code review ACK faec889f938f90e0b887426db27a15ec0d169399
stickies-v:
ACK faec889f938f90e0b887426db27a15ec0d169399
pablomartin4btc:
cr ACK faec889f938f90e0b887426db27a15ec0d169399
Tree-SHA512: 0c2a151f39d0e007b4d33b0b85ad578cc220f3e9dd94890e812b3181c3901545b039325707731cc39a5e89557f59c1154c6320525f78f5de95f119a514d2d23f
Diffstat (limited to 'src/util/transaction_identifier.h')
-rw-r--r-- | src/util/transaction_identifier.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util/transaction_identifier.h b/src/util/transaction_identifier.h index 77f4b8367d..4fb9b49966 100644 --- a/src/util/transaction_identifier.h +++ b/src/util/transaction_identifier.h @@ -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. */ |