Convert macros in STTX.h into an enum

This commit is contained in:
Joe Loser
2018-05-12 12:09:44 -04:00
committed by seelabs
parent 817d2339b8
commit dc0d5996e2
3 changed files with 17 additions and 15 deletions

View File

@@ -63,18 +63,18 @@ void Transaction::setStatus (TransStatus ts, std::uint32_t lseq)
TransStatus Transaction::sqlTransactionStatus( TransStatus Transaction::sqlTransactionStatus(
boost::optional<std::string> const& status) boost::optional<std::string> const& status)
{ {
char const c = (status) ? (*status)[0] : TXN_SQL_UNKNOWN; char const c = (status) ? (*status)[0] : txnSqlUnknown;
switch (c) switch (c)
{ {
case TXN_SQL_NEW: return NEW; case txnSqlNew: return NEW;
case TXN_SQL_CONFLICT: return CONFLICTED; case txnSqlConflict: return CONFLICTED;
case TXN_SQL_HELD: return HELD; case txnSqlHeld: return HELD;
case TXN_SQL_VALIDATED: return COMMITTED; case txnSqlValidated: return COMMITTED;
case TXN_SQL_INCLUDED: return INCLUDED; case txnSqlIncluded: return INCLUDED;
} }
assert (c == TXN_SQL_UNKNOWN); assert (c == txnSqlUnknown);
return INVALID; return INVALID;
} }

View File

@@ -30,13 +30,15 @@
namespace ripple { namespace ripple {
// VFALCO TODO replace these macros with language constants enum TxnSql : char
#define TXN_SQL_NEW 'N' {
#define TXN_SQL_CONFLICT 'C' txnSqlNew = 'N',
#define TXN_SQL_HELD 'H' txnSqlConflict = 'C',
#define TXN_SQL_VALIDATED 'V' txnSqlHeld = 'H',
#define TXN_SQL_INCLUDED 'I' txnSqlValidated = 'V',
#define TXN_SQL_UNKNOWN 'U' txnSqlIncluded = 'I',
txnSqlUnknown = 'U'
};
class STTx final class STTx final
: public STObject : public STObject

View File

@@ -240,7 +240,7 @@ std::string STTx::getMetaSQL (std::uint32_t inLedger,
{ {
Serializer s; Serializer s;
add (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 // VFALCO This could be a free function elsewhere