diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 41f5937c46..db89d1f4eb 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -2585,6 +2585,8 @@ True + + True @@ -2605,6 +2607,8 @@ + + True @@ -3327,6 +3331,8 @@ + + @@ -3337,6 +3343,8 @@ + + @@ -3345,8 +3353,6 @@ - - @@ -3371,10 +3377,10 @@ True - + True - + True @@ -3723,6 +3729,8 @@ + + @@ -3796,6 +3804,11 @@ + + True + + + True @@ -3836,6 +3849,11 @@ + + True + + + True @@ -3930,6 +3948,11 @@ + + True + + + True diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 59b7332d4c..63bfa1277a 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -3690,6 +3690,9 @@ ripple\module\data\protocol + + ripple\module\data\protocol + ripple\module\data\protocol @@ -3714,6 +3717,9 @@ ripple\module\data\protocol + + ripple\module\data\protocol + ripple\module\data\protocol @@ -4572,6 +4578,9 @@ ripple\types\api + + ripple\types\api + ripple\types\api @@ -4587,6 +4596,9 @@ ripple\types\api + + ripple\types\api + ripple\types\api @@ -4599,9 +4611,6 @@ ripple\types\api - - ripple\types\api - ripple\types\api @@ -4635,10 +4644,10 @@ ripple\types\impl - + ripple\types\impl - + ripple\types\impl @@ -5085,6 +5094,9 @@ rocksdb\include\rocksdb + + rocksdb\include\rocksdb + rocksdb\include\rocksdb @@ -5184,6 +5196,12 @@ rocksdb\table + + rocksdb\table + + + rocksdb\table + rocksdb\table @@ -5232,6 +5250,12 @@ rocksdb\table + + rocksdb\table + + + rocksdb\table + rocksdb\table @@ -5343,6 +5367,12 @@ rocksdb\util + + rocksdb\util + + + rocksdb\util + rocksdb\util diff --git a/src/beast/beast/http/impl/message_parser.cpp b/src/beast/beast/http/impl/message_parser.cpp index a2caefa4a1..61db041d48 100644 --- a/src/beast/beast/http/impl/message_parser.cpp +++ b/src/beast/beast/http/impl/message_parser.cpp @@ -72,8 +72,9 @@ message_parser::check_url() { checked_url_ = true; auto const p (reinterpret_cast (&state_)); - ec_ = on_request (joyent::convert_http_method ( - joyent::http_method(p->method)), p->http_major, p->http_minor, url_); + ec_ = on_request ( + joyent::convert_http_method (joyent::http_method(p->method)), + p->http_major, p->http_minor, url_); if (ec_) return 1; } @@ -96,7 +97,6 @@ message_parser::do_url (char const* in, std::size_t bytes) int message_parser::do_status (char const* in, std::size_t bytes) { - auto const p (reinterpret_cast (&state_)); return ec_ ? 1 : 0; } @@ -132,8 +132,6 @@ message_parser::do_headers_done () { if (check_url()) return 1; - auto const p (reinterpret_cast (&state_)); - bool const keep_alive (joyent::http_should_keep_alive (p) != 0); if (! value_.empty()) { ec_ = on_field (field_, value_); @@ -148,17 +146,12 @@ message_parser::do_headers_done () int message_parser::do_body (char const* in, std::size_t bytes) { - auto const p (reinterpret_cast (&state_)); - bool const is_final ( - joyent::http_body_is_final (p) != 0); return ec_ ? 1 : 0; } int message_parser::do_message_complete () { - auto const p (reinterpret_cast (&state_)); - bool const keep_alive (joyent::http_should_keep_alive (p) != 0); complete_ = true; return 0; } diff --git a/src/ripple/module/app/ledger/LedgerEntrySet.cpp b/src/ripple/module/app/ledger/LedgerEntrySet.cpp index 099fa1961b..c629000c2c 100644 --- a/src/ripple/module/app/ledger/LedgerEntrySet.cpp +++ b/src/ripple/module/app/ledger/LedgerEntrySet.cpp @@ -1055,6 +1055,8 @@ void LedgerEntrySet::ownerCountAdjust ( TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer) { + if (!sleOffer) + return tesSUCCESS; auto offerIndex = sleOffer->getIndex (); auto owner = sleOffer->getFieldAccount160 (sfAccount); @@ -1079,16 +1081,6 @@ TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer) return (terResult == tesSUCCESS) ? terResult2 : terResult; } -TER LedgerEntrySet::offerDelete (uint256 const& offerIndex) -{ - SLE::pointer sleOffer = entryCache (ltOFFER, offerIndex); - - if (!sleOffer) - return tesSUCCESS; - - return offerDelete (sleOffer); -} - // Returns amount owed by uToAccountID to uFromAccountID. // <-- $owed/currency/uToAccountID: // positive: uFromAccountID holds IOUs., diff --git a/src/ripple/module/app/ledger/LedgerEntrySet.h b/src/ripple/module/app/ledger/LedgerEntrySet.h index 5b0384f4f4..42f8d7374f 100644 --- a/src/ripple/module/app/ledger/LedgerEntrySet.h +++ b/src/ripple/module/app/ledger/LedgerEntrySet.h @@ -84,7 +84,7 @@ public: static char const* getCountedObjectName () { return "LedgerEntrySet"; } LedgerEntrySet ( - Ledger::ref ledger, TransactionEngineParams tep, bool immutable = false) + Ledger::ref ledger, TransactionEngineParams tep, bool immutable = false) : mLedger (ledger), mParams (tep), mSeq (0), mImmutable (immutable) { } @@ -180,15 +180,18 @@ public: bool dirIsEmpty (uint256 const& uDirIndex); TER dirCount (uint256 const& uDirIndex, std::uint32_t & uCount); - uint256 getNextLedgerIndex (uint256 const & uHash); - uint256 getNextLedgerIndex (uint256 const & uHash, uint256 const & uEnd); + uint256 getNextLedgerIndex (uint256 const& uHash); + uint256 getNextLedgerIndex (uint256 const& uHash, uint256 const & uEnd); void ownerCountAdjust (Account const& uOwnerID, int iAmount, SLE::ref sleAccountRoot = SLE::pointer ()); // Offer functions. - TER offerDelete (uint256 const & offerIndex); - TER offerDelete (SLE::pointer sleOffer); + TER offerDelete (SLE::pointer); + TER offerDelete (uint256 const& offerIndex) + { + return offerDelete( entryCache (ltOFFER, offerIndex)); + } // Balance functions. std::uint32_t rippleTransferRate (Account const& issuer); diff --git a/src/ripple/module/data/protocol/TER.cpp b/src/ripple/module/data/protocol/TER.cpp index 4d5fefb959..99cbb109ca 100644 --- a/src/ripple/module/data/protocol/TER.cpp +++ b/src/ripple/module/data/protocol/TER.cpp @@ -36,7 +36,7 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { tecNO_DST, "tecNO_DST", "Destination does not exist. Send XRP to create it." }, { tecNO_DST_INSUF_XRP, "tecNO_DST_INSUF_XRP", "Destination does not exist. Too little XRP sent to create it." }, { tecNO_LINE_INSUF_RESERVE, "tecNO_LINE_INSUF_RESERVE", "No such line. Too little reserve to create it." }, - { tecNO_LINE_REDUNDANT, "tecNO_LINE_REDUNDANT", "Can't set non-existant line to default." }, + { tecNO_LINE_REDUNDANT, "tecNO_LINE_REDUNDANT", "Can't set non-existent line to default." }, { tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." }, { tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." }, { tecMASTER_DISABLED, "tecMASTER_DISABLED", "Master key is disabled." }, @@ -51,24 +51,20 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { tecNO_AUTH, "tecNO_AUTH", "Not authorized to hold asset." }, { tecNO_LINE, "tecNO_LINE", "No such line." }, - { tefFAILURE, "tefFAILURE", "Failed to apply." }, { tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." }, { tefBAD_ADD_AUTH, "tefBAD_ADD_AUTH", "Not authorized to add account." }, { tefBAD_AUTH, "tefBAD_AUTH", "Transaction's public key is not authorized." }, - { tefBAD_CLAIM_ID, "tefBAD_CLAIM_ID", "Malformed: Bad claim id." }, - { tefBAD_GEN_AUTH, "tefBAD_GEN_AUTH", "Not authorized to claim generator." }, { tefBAD_LEDGER, "tefBAD_LEDGER", "Ledger in unexpected state." }, - { tefCLAIMED, "tefCLAIMED", "Can not claim a previously claimed account." }, { tefCREATED, "tefCREATED", "Can't add an already created account." }, { tefDST_TAG_NEEDED, "tefDST_TAG_NEEDED", "Destination tag required." }, { tefEXCEPTION, "tefEXCEPTION", "Unexpected program state." }, - { tefGEN_IN_USE, "tefGEN_IN_USE", "Generator already in use." }, + { tefFAILURE, "tefFAILURE", "Failed to apply." }, { tefINTERNAL, "tefINTERNAL", "Internal error." }, + { tefMASTER_DISABLED, "tefMASTER_DISABLED", "Master key is disabled." }, + { tefMAX_LEDGER, "tefMAX_LEDGER", "Ledger sequence too high." }, { tefNO_AUTH_REQUIRED, "tefNO_AUTH_REQUIRED", "Auth is not required." }, { tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." }, { tefWRONG_PRIOR, "tefWRONG_PRIOR", "This previous transaction does not match." }, - { tefMASTER_DISABLED, "tefMASTER_DISABLED", "Master key is disabled." }, - { tefMAX_LEDGER, "tefMAX_LEDGER", "Ledger sequence too high." }, { telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." }, { telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." }, @@ -82,23 +78,22 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { temBAD_AMOUNT, "temBAD_AMOUNT", "Can only send positive amounts." }, { temBAD_AUTH_MASTER, "temBAD_AUTH_MASTER", "Auth for unclaimed account needs correct master key." }, { temBAD_CURRENCY, "temBAD_CURRENCY", "Malformed: Bad currency." }, - { temBAD_FEE, "temBAD_FEE", "Invalid fee, negative or not XRP." }, { temBAD_EXPIRATION, "temBAD_EXPIRATION", "Malformed: Bad expiration." }, + { temBAD_FEE, "temBAD_FEE", "Invalid fee, negative or not XRP." }, { temBAD_ISSUER, "temBAD_ISSUER", "Malformed: Bad issuer." }, { temBAD_LIMIT, "temBAD_LIMIT", "Limits must be non-negative." }, { temBAD_OFFER, "temBAD_OFFER", "Malformed: Bad offer." }, { temBAD_PATH, "temBAD_PATH", "Malformed: Bad path." }, { temBAD_PATH_LOOP, "temBAD_PATH_LOOP", "Malformed: Loop in path." }, - { temBAD_PUBLISH, "temBAD_PUBLISH", "Malformed: Bad publish." }, - { temBAD_SIGNATURE, "temBAD_SIGNATURE", "Malformed: Bad signature." }, - { temBAD_SRC_ACCOUNT, "temBAD_SRC_ACCOUNT", "Malformed: Bad source account." }, - { temBAD_TRANSFER_RATE, "temBAD_TRANSFER_RATE", "Malformed: Transfer rate must be >= 1.0" }, - { temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence is not in the past." }, { temBAD_SEND_XRP_LIMIT, "temBAD_SEND_XRP_LIMIT", "Malformed: Limit quality is not allowed for XRP to XRP." }, { temBAD_SEND_XRP_MAX, "temBAD_SEND_XRP_MAX", "Malformed: Send max is not allowed for XRP to XRP." }, { temBAD_SEND_XRP_NO_DIRECT, "temBAD_SEND_XRP_NO_DIRECT", "Malformed: No Ripple direct is not allowed for XRP to XRP." }, { temBAD_SEND_XRP_PARTIAL, "temBAD_SEND_XRP_PARTIAL", "Malformed: Partial payment is not allowed for XRP to XRP." }, { temBAD_SEND_XRP_PATHS, "temBAD_SEND_XRP_PATHS", "Malformed: Paths are not allowed for XRP to XRP." }, + { temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence is not in the past." }, + { temBAD_SIGNATURE, "temBAD_SIGNATURE", "Malformed: Bad signature." }, + { temBAD_SRC_ACCOUNT, "temBAD_SRC_ACCOUNT", "Malformed: Bad source account." }, + { temBAD_TRANSFER_RATE, "temBAD_TRANSFER_RATE", "Malformed: Transfer rate must be >= 1.0" }, { temDST_IS_SRC, "temDST_IS_SRC", "Destination may not be source." }, { temDST_NEEDED, "temDST_NEEDED", "Destination not specified." }, { temINVALID, "temINVALID", "The transaction is ill-formed." }, diff --git a/src/ripple/module/data/protocol/TER.h b/src/ripple/module/data/protocol/TER.h index 137966688f..5acfd55bcd 100644 --- a/src/ripple/module/data/protocol/TER.h +++ b/src/ripple/module/data/protocol/TER.h @@ -24,10 +24,6 @@ namespace ripple { // See https://ripple.com/wiki/Transaction_errors -// VFALCO TODO do not use auto-incrementing. Explicitly assign each -// constant so there is no possibility of someone coming in -// and screwing it up. -// // VFALCO TODO consider renaming TER to TxErr or TxResult for clarity. // enum TER // aka TransactionEngineResult @@ -40,7 +36,7 @@ enum TER // aka TransactionEngineResult // - Not forwarded // - No fee check telLOCAL_ERROR = -399, - telBAD_DOMAIN, // VFALCO TODO should read "telBAD_DOMAIN = -398," etc... + telBAD_DOMAIN, telBAD_PATH_COUNT, telBAD_PUBLIC_KEY, telFAILED_PROCESSING, @@ -56,26 +52,26 @@ enum TER // aka TransactionEngineResult // - Reject // - Can not succeed in any imagined ledger. temMALFORMED = -299, + temBAD_AMOUNT, temBAD_AUTH_MASTER, temBAD_CURRENCY, - temBAD_FEE, temBAD_EXPIRATION, + temBAD_FEE, temBAD_ISSUER, temBAD_LIMIT, temBAD_OFFER, temBAD_PATH, temBAD_PATH_LOOP, - temBAD_PUBLISH, - temBAD_TRANSFER_RATE, temBAD_SEND_XRP_LIMIT, temBAD_SEND_XRP_MAX, temBAD_SEND_XRP_NO_DIRECT, temBAD_SEND_XRP_PARTIAL, temBAD_SEND_XRP_PATHS, + temBAD_SEQUENCE, temBAD_SIGNATURE, temBAD_SRC_ACCOUNT, - temBAD_SEQUENCE, + temBAD_TRANSFER_RATE, temDST_IS_SRC, temDST_NEEDED, temINVALID, @@ -83,14 +79,19 @@ enum TER // aka TransactionEngineResult temREDUNDANT, temREDUNDANT_SEND_MAX, temRIPPLE_EMPTY, - temUNCERTAIN, // An intermediate result used internally, should never be returned. + + // An intermediate result used internally, should never be returned. + temUNCERTAIN, temUNKNOWN, - // -199 .. -100: F Failure (sequence number previously used) + // -199 .. -100: F + // Failure (sequence number previously used) + // // Causes: // - Transaction cannot succeed because of ledger state. // - Unexpected ledger state. // - C++ exception. + // // Implications: // - Not applied // - Not forwarded @@ -99,14 +100,10 @@ enum TER // aka TransactionEngineResult tefALREADY, tefBAD_ADD_AUTH, tefBAD_AUTH, - tefBAD_CLAIM_ID, - tefBAD_GEN_AUTH, tefBAD_LEDGER, - tefCLAIMED, tefCREATED, tefDST_TAG_NEEDED, tefEXCEPTION, - tefGEN_IN_USE, tefINTERNAL, tefNO_AUTH_REQUIRED, // Can't set auth if auth is not required. tefPAST_SEQ, @@ -114,9 +111,14 @@ enum TER // aka TransactionEngineResult tefMASTER_DISABLED, tefMAX_LEDGER, - // -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent) - // Causes: - // - Prior application of another, possibly non-existant, another transaction could allow this transaction to succeed. + // -99 .. -1: R Retry + // sequence too high, no funds for txn fee, originating -account + // non-existent + // + // Cause: + // Prior application of another, possibly non-existent, transaction could + // allow this transaction to succeed. + // // Implications: // - Not applied // - Not forwarded @@ -124,15 +126,16 @@ enum TER // aka TransactionEngineResult // - Hold // - Makes hole in sequence which jams transactions. terRETRY = -99, - terFUNDS_SPENT, // This is a free transaction, therefore don't burden network. - terINSUF_FEE_B, // Can't pay fee, therefore don't burden network. - terNO_ACCOUNT, // Can't pay fee, therefore don't burden network. - terNO_AUTH, // Not authorized to hold IOUs. - terNO_LINE, // Internal flag. - terOWNERS, // Can't succeed with non-zero owner count. - terPRE_SEQ, // Can't pay fee, no point in forwarding, therefore don't burden network. - terLAST, // Process after all other transactions - terNO_RIPPLE, // Rippling not allowed + terFUNDS_SPENT, // This is a free transaction, so don't burden network. + terINSUF_FEE_B, // Can't pay fee, therefore don't burden network. + terNO_ACCOUNT, // Can't pay fee, therefore don't burden network. + terNO_AUTH, // Not authorized to hold IOUs. + terNO_LINE, // Internal flag. + terOWNERS, // Can't succeed with non-zero owner count. + terPRE_SEQ, // Can't pay fee, no point in forwarding, so don't + // burden network. + terLAST, // Process after all other transactions + terNO_RIPPLE, // Rippling not allowed // 0: S Success (success) // Causes: @@ -142,14 +145,21 @@ enum TER // aka TransactionEngineResult // - Forwarded tesSUCCESS = 0, - // 100 .. 159 C Claim fee only (ripple transaction with no good paths, pay to non-existent account, no path) + // 100 .. 159 C + // Claim fee only (ripple transaction with no good paths, pay to + // non-existent account, no path) + // // Causes: // - Success, but does not achieve optimal result. - // - Invalid transaction or no effect, but claim fee to use the sequence number. + // - Invalid transaction or no effect, but claim fee to use the sequence + // number. + // // Implications: // - Applied // - Forwarded - // Only allowed as a return code of appliedTransaction when !tapRetry. Otherwise, treated as terRETRY. + // + // Only allowed as a return code of appliedTransaction when !tapRetry. + // Otherwise, treated as terRETRY. // // DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data. tecCLAIM = 100, @@ -175,13 +185,35 @@ enum TER // aka TransactionEngineResult tecNO_LINE = 135, }; -// VFALCO TODO change these to normal functions. -#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED) -#define isTemMalformed(x) ((x) >= temMALFORMED && (x) < tefFAILURE) -#define isTefFailure(x) ((x) >= tefFAILURE && (x) < terRETRY) -#define isTerRetry(x) ((x) >= terRETRY && (x) < tesSUCCESS) -#define isTesSuccess(x) ((x) == tesSUCCESS) -#define isTecClaim(x) ((x) >= tecCLAIM) +inline bool isTelLocal(TER x) +{ + return ((x) >= telLOCAL_ERROR && (x) < temMALFORMED); +} + +inline bool isTemMalformed(TER x) +{ + return ((x) >= temMALFORMED && (x) < tefFAILURE); +} + +inline bool isTefFailure(TER x) +{ + return ((x) >= tefFAILURE && (x) < terRETRY); +} + +inline bool isTerRetry(TER x) +{ + return ((x) >= terRETRY && (x) < tesSUCCESS); +} + +inline bool isTesSuccess(TER x) +{ + return ((x) == tesSUCCESS); +} + +inline bool isTecClaim(TER x) +{ + return ((x) >= tecCLAIM); +} // VFALCO TODO group these into a shell class along with the defines above. extern bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman);