From 7e2bf8e52278d0c000d770ab4e60ba660f139eaf Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 15 Apr 2013 22:59:16 -0700 Subject: [PATCH] Change/Fee transactor. Conflicts: src/cpp/ripple/LedgerEntrySet.h --- src/cpp/ripple/LedgerEntrySet.h | 8 +++++--- src/cpp/ripple/SerializedTypes.cpp | 11 +++++++++++ src/cpp/ripple/SerializedTypes.h | 2 +- src/cpp/ripple/TransactionErr.cpp | 1 + src/cpp/ripple/TransactionErr.h | 1 + src/cpp/ripple/Transactor.cpp | 6 ++++++ src/cpp/ripple/Transactor.h | 6 +++--- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/cpp/ripple/LedgerEntrySet.h b/src/cpp/ripple/LedgerEntrySet.h index cbac5b1e96..10fe105a62 100644 --- a/src/cpp/ripple/LedgerEntrySet.h +++ b/src/cpp/ripple/LedgerEntrySet.h @@ -16,14 +16,16 @@ enum TransactionEngineParams { tapNONE = 0x00, - tapNO_CHECK_SIGN = 0x01, // Signature already checked + tapNO_CHECK_SIGN = 0x01, // Signature already checked - tapOPEN_LEDGER = 0x10, // Transaction is running against an open ledger + tapOPEN_LEDGER = 0x10, // Transaction is running against an open ledger // true = failures are not forwarded, check transaction fee // false = debit ledger for consumed funds - tapRETRY = 0x20, // This is not the transaction's last pass + tapRETRY = 0x20, // This is not the transaction's last pass // Transaction can be retried, soft failures allowed + + tapADMIN = 0x400, // Transaction came from a privileged source }; enum LedgerEntryAction diff --git a/src/cpp/ripple/SerializedTypes.cpp b/src/cpp/ripple/SerializedTypes.cpp index cedb1be72e..27f999c484 100644 --- a/src/cpp/ripple/SerializedTypes.cpp +++ b/src/cpp/ripple/SerializedTypes.cpp @@ -315,6 +315,17 @@ bool STVector256::isEquivalent(const SerializedType& t) const return v && (mValue == v->mValue); } +bool STVector256::hasValue(const uint256& v) const +{ + BOOST_FOREACH(const uint256& hash, mValue) + { + if (hash == v) + return true; + } + + return false; +} + // // STAccount // diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index c0a4fd4529..c2047a52b0 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -869,7 +869,7 @@ public: void setValue(const STVector256& v) { mValue = v.mValue; } void setValue(const std::vector& v) { mValue = v; } void addValue(const uint256& v) { mValue.push_back(v); } - + bool hasValue(const uint256& v) const; Json::Value getJson(int) const; }; diff --git a/src/cpp/ripple/TransactionErr.cpp b/src/cpp/ripple/TransactionErr.cpp index 04fcb1d2eb..778aa9a06a 100644 --- a/src/cpp/ripple/TransactionErr.cpp +++ b/src/cpp/ripple/TransactionErr.cpp @@ -83,6 +83,7 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) { terRETRY, "terRETRY", "Retry transaction." }, { terFUNDS_SPENT, "terFUNDS_SPENT", "Can't set password, password set funds already spent." }, { terINSUF_FEE_B, "terINSUF_FEE_B", "Account balance can't pay fee." }, + { terLAST, "terLAST", "Process last." }, { terNO_ACCOUNT, "terNO_ACCOUNT", "The source account does not exist." }, { terNO_AUTH, "terNO_AUTH", "Not authorized to hold IOUs." }, { terNO_LINE, "terNO_LINE", "No such line." }, diff --git a/src/cpp/ripple/TransactionErr.h b/src/cpp/ripple/TransactionErr.h index 7df06c8f71..59eea621d7 100644 --- a/src/cpp/ripple/TransactionErr.h +++ b/src/cpp/ripple/TransactionErr.h @@ -101,6 +101,7 @@ enum TER // aka TransactionEngineResult 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 // 0: S Success (success) // Causes: diff --git a/src/cpp/ripple/Transactor.cpp b/src/cpp/ripple/Transactor.cpp index c7924b7a80..7b4aad602d 100644 --- a/src/cpp/ripple/Transactor.cpp +++ b/src/cpp/ripple/Transactor.cpp @@ -8,6 +8,7 @@ #include "OfferCancelTransactor.h" #include "OfferCreateTransactor.h" #include "TrustSetTransactor.h" +#include "ChangeTransactor.h" SETUP_LOG(); @@ -29,6 +30,11 @@ UPTR_T Transactor::makeTransactor(const SerializedTransaction& txn,T return UPTR_T(new OfferCancelTransactor(txn, params, engine)); case ttWALLET_ADD: return UPTR_T(new WalletAddTransactor(txn, params, engine)); + + case ttFEATURE: + case ttFEE: + return UPTR_T(new ChangeTransactor(txn, params, engine)); + default: return UPTR_T(); } diff --git a/src/cpp/ripple/Transactor.h b/src/cpp/ripple/Transactor.h index f530b6f9c1..d72bd4b742 100644 --- a/src/cpp/ripple/Transactor.h +++ b/src/cpp/ripple/Transactor.h @@ -22,9 +22,9 @@ protected: bool mHasAuthKey; RippleAddress mSigningPubKey; - TER preCheck(); - TER checkSeq(); - TER payFee(); + virtual TER preCheck(); + virtual TER checkSeq(); + virtual TER payFee(); void calculateFee();