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(
boost::optional<std::string> 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;
}

View File

@@ -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

View File

@@ -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