From 5321786b9d90eaf35059bb07e6beaaa2cbb257ac Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 23 Jan 2023 16:59:25 -0500 Subject: coincontrol: Replace HasInputWeight with returning optional from Get --- src/wallet/coincontrol.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/wallet/coincontrol.cpp') diff --git a/src/wallet/coincontrol.cpp b/src/wallet/coincontrol.cpp index a4f3bdac23..94218b45c1 100644 --- a/src/wallet/coincontrol.cpp +++ b/src/wallet/coincontrol.cpp @@ -72,15 +72,10 @@ void CCoinControl::SetInputWeight(const COutPoint& outpoint, int64_t weight) m_selected[outpoint].SetInputWeight(weight); } -bool CCoinControl::HasInputWeight(const COutPoint& outpoint) const +std::optional CCoinControl::GetInputWeight(const COutPoint& outpoint) const { const auto it = m_selected.find(outpoint); - return it != m_selected.end() && it->second.HasInputWeight(); -} - -int64_t CCoinControl::GetInputWeight(const COutPoint& outpoint) const -{ - return m_selected.at(outpoint).GetInputWeight(); + return it != m_selected.end() ? it->second.GetInputWeight() : std::nullopt; } void PreselectedInput::SetTxOut(const CTxOut& txout) @@ -104,14 +99,8 @@ void PreselectedInput::SetInputWeight(int64_t weight) m_weight = weight; } -int64_t PreselectedInput::GetInputWeight() const -{ - assert(m_weight.has_value()); - return m_weight.value(); -} - -bool PreselectedInput::HasInputWeight() const +std::optional PreselectedInput::GetInputWeight() const { - return m_weight.has_value(); + return m_weight; } } // namespace wallet -- cgit v1.2.3