From 5471072d2ee09acb50144dd8dc9a1257700ae513 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 6 Jun 2019 12:50:44 -0400 Subject: [PATCH] cpp project compiling with boost::optional --- src/wallet/MoneroWallet.cpp | 8 ++++---- src/wallet/MoneroWallet.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index 97ee482..baa4318 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -14,7 +14,7 @@ namespace monero { // ---------------------------- PRIVATE HELPERS ----------------------------- - bool boolEquals(bool val, boost::optional optVal) { + bool boolEquals(bool val, const boost::optional& optVal) { return optVal == boost::none ? false : val == *optVal; } @@ -494,9 +494,9 @@ namespace monero { // translate from MoneroTxRequest to in, out, pending, pool, failed terminology bool canBeConfirmed = !boolEquals(false, txReq.isConfirmed) && !boolEquals(true, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed); - bool canBeInTxPool = !boolEquals(true, txReq.isConfirmed) && !boolEquals(false, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed) && txReq.height == boost::none && txReq.minHeight == boost::none; - bool canBeIncoming = !boolEquals(false, request.isIncoming) && !boolEquals(true, request.isOutgoing) && !boolEquals(true, request.hasDestinations); - bool canBeOutgoing = !boolEquals(false, request.isOutgoing) && !boolEquals(true, request.isIncoming); + bool canBeInTxPool = !boolEquals(true, txReq.isConfirmed) && !boolEquals(false, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed) && txReq.getHeight() == boost::none && txReq.minHeight == boost::none; + bool canBeIncoming = !boolEquals(false, request.isIncoming) && !boolEquals(true, request.getIsOutgoing()) && !boolEquals(true, request.hasDestinations); + bool canBeOutgoing = !boolEquals(false, request.getIsOutgoing()) && !boolEquals(true, request.isIncoming); bool isIn = canBeIncoming && canBeConfirmed; bool isOut = canBeOutgoing && canBeConfirmed; bool isPending = canBeOutgoing && canBeInTxPool; diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index c620850..0342f30 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -146,6 +146,11 @@ namespace monero { vector destinations; boost::optional hasDestinations; boost::optional> txRequest; + + boost::optional getIsOutgoing() const { + if (isIncoming == boost::none ) return boost::none; + return !(*isIncoming); + } }; /** @@ -163,6 +168,8 @@ namespace monero { boost::optional maxHeight; boost::optional includeOutputs; boost::optional transferRequest; + + boost::optional getHeight() { return block == boost::none ? boost::none : (*block)->height; } }; /**