From 77771a03df6c5d940b340d15eb88f2ac9a29c13a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 22 Sep 2020 16:06:02 +0200 Subject: refactor: Remove SignetTxs::m_valid and use optional instead m_valid implies the block solution has been checked, which is not the case. It only means the txs could be parsed. C++17 comes with std::optional, so just use that instead. --- src/signet.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/signet.h') diff --git a/src/signet.h b/src/signet.h index 5694716fb6..23563a83c4 100644 --- a/src/signet.h +++ b/src/signet.h @@ -9,6 +9,8 @@ #include #include +#include + /** * Extract signature and check whether a block has a valid solution */ @@ -22,21 +24,14 @@ bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& cons * 2. It skips the nonce. */ class SignetTxs { -private: - struct invalid {}; - SignetTxs(invalid i) : m_to_spend(), m_to_sign(), m_valid(false) { } - template - SignetTxs(const T1& to_spend, const T2& to_sign) : m_to_spend{to_spend}, m_to_sign{to_sign}, m_valid(true) { } - - static SignetTxs Create(const CBlock& block, const CScript& challenge); + SignetTxs(const T1& to_spend, const T2& to_sign) : m_to_spend{to_spend}, m_to_sign{to_sign} { } public: - SignetTxs(const CBlock& block, const CScript& challenge) : SignetTxs(Create(block, challenge)) { } + static Optional Create(const CBlock& block, const CScript& challenge); const CTransaction m_to_spend; const CTransaction m_to_sign; - const bool m_valid; }; #endif // BITCOIN_SIGNET_H -- cgit v1.2.3