From dc0d5996e21a0739baf1b9aa50b4f2ad43463421 Mon Sep 17 00:00:00 2001 From: Joe Loser Date: Sat, 12 May 2018 12:09:44 -0400 Subject: [PATCH] Convert macros in STTX.h into an enum --- src/ripple/app/misc/impl/Transaction.cpp | 14 +++++++------- src/ripple/protocol/STTx.h | 16 +++++++++------- src/ripple/protocol/impl/STTx.cpp | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/ripple/app/misc/impl/Transaction.cpp b/src/ripple/app/misc/impl/Transaction.cpp index 4b04a2f591..f29b11b8f0 100644 --- a/src/ripple/app/misc/impl/Transaction.cpp +++ b/src/ripple/app/misc/impl/Transaction.cpp @@ -63,18 +63,18 @@ void Transaction::setStatus (TransStatus ts, std::uint32_t lseq) TransStatus Transaction::sqlTransactionStatus( boost::optional const& status) { - char const c = (status) ? (*status)[0] : TXN_SQL_UNKNOWN; + char const c = (status) ? (*status)[0] : txnSqlUnknown; switch (c) { - case TXN_SQL_NEW: return NEW; - case TXN_SQL_CONFLICT: return CONFLICTED; - case TXN_SQL_HELD: return HELD; - case TXN_SQL_VALIDATED: return COMMITTED; - case TXN_SQL_INCLUDED: return INCLUDED; + case txnSqlNew: return NEW; + case txnSqlConflict: return CONFLICTED; + case txnSqlHeld: return HELD; + case txnSqlValidated: return COMMITTED; + case txnSqlIncluded: return INCLUDED; } - assert (c == TXN_SQL_UNKNOWN); + assert (c == txnSqlUnknown); return INVALID; } diff --git a/src/ripple/protocol/STTx.h b/src/ripple/protocol/STTx.h index 6ab0035bb0..43f0747a3b 100644 --- a/src/ripple/protocol/STTx.h +++ b/src/ripple/protocol/STTx.h @@ -30,13 +30,15 @@ namespace ripple { -// VFALCO TODO replace these macros with language constants -#define TXN_SQL_NEW 'N' -#define TXN_SQL_CONFLICT 'C' -#define TXN_SQL_HELD 'H' -#define TXN_SQL_VALIDATED 'V' -#define TXN_SQL_INCLUDED 'I' -#define TXN_SQL_UNKNOWN 'U' +enum TxnSql : char +{ + txnSqlNew = 'N', + txnSqlConflict = 'C', + txnSqlHeld = 'H', + txnSqlValidated = 'V', + txnSqlIncluded = 'I', + txnSqlUnknown = 'U' +}; class STTx final : public STObject diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/ripple/protocol/impl/STTx.cpp index 4547e5e142..a101ba7619 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -240,7 +240,7 @@ std::string STTx::getMetaSQL (std::uint32_t inLedger, { Serializer s; add (s); - return getMetaSQL (s, inLedger, TXN_SQL_VALIDATED, escapedMetaData); + return getMetaSQL (s, inLedger, txnSqlValidated, escapedMetaData); } // VFALCO This could be a free function elsewhere