Skip to content

Commit

Permalink
Convert macros in STTX.h into an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeLoser authored and seelabs committed Jun 1, 2018
1 parent 817d233 commit dc0d599
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/ripple/app/misc/impl/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 9 additions & 7 deletions src/ripple/protocol/STTx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/STTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc0d599

Please sign in to comment.