diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2016-11-10 17:34:17 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2016-11-19 17:53:23 -0800 |
commit | b4e4ba475a5679e09f279aaf2a83dcf93c632bdb (patch) | |
tree | 31f4d8edd5134e92bf133ee3dfd52651c14ed21e /src/primitives | |
parent | 1662b437b33b7ec5a1723f6ae6187d3bdd06f593 (diff) |
Introduce convenience type CTransactionRef
Diffstat (limited to 'src/primitives')
-rw-r--r-- | src/primitives/block.h | 2 | ||||
-rw-r--r-- | src/primitives/transaction.h | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/primitives/block.h b/src/primitives/block.h index 45b4895eba..b037fc839c 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -73,7 +73,7 @@ class CBlock : public CBlockHeader { public: // network and disk - std::vector<std::shared_ptr<const CTransaction>> vtx; + std::vector<CTransactionRef> vtx; // memory only mutable bool fChecked; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 015a89ff10..0fa85a1519 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -475,6 +475,12 @@ struct CMutableTransaction uint256 GetHash() const; }; +typedef std::shared_ptr<const CTransaction> CTransactionRef; +static inline CTransactionRef MakeTransactionRef() { return std::make_shared<const CTransaction>(); } +template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); } +static inline CTransactionRef MakeTransactionRef(const CTransactionRef& txIn) { return txIn; } +static inline CTransactionRef MakeTransactionRef(CTransactionRef&& txIn) { return std::move(txIn); } + /** Compute the weight of a transaction, as defined by BIP 141 */ int64_t GetTransactionWeight(const CTransaction &tx); |