diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-09-22 16:06:02 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-09-22 22:31:31 +0200 |
commit | 77771a03df6c5d940b340d15eb88f2ac9a29c13a (patch) | |
tree | 86a77309fb4805f15d5e8ee44858e44d020ca937 /src/signet.h | |
parent | fa2ad5dae17b237641b8ece0e68ffcdd79d543bf (diff) |
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.
Diffstat (limited to 'src/signet.h')
-rw-r--r-- | src/signet.h | 13 |
1 files changed, 4 insertions, 9 deletions
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 <primitives/block.h> #include <primitives/transaction.h> +#include <optional.h> + /** * 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<class T1, class T2> - 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<SignetTxs> 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 |