From efb3c24518347408c89dfea59e3ec4a56fd3d711 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 15 Apr 2013 22:59:16 -0700 Subject: [PATCH] Change/Fee transactor. --- src/cpp/ripple/LedgerEntrySet.h | 10 ++++++---- 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/TransactionFormats.cpp | 3 +-- src/cpp/ripple/Transactor.cpp | 6 ++++++ src/cpp/ripple/Transactor.h | 6 +++--- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/cpp/ripple/LedgerEntrySet.h b/src/cpp/ripple/LedgerEntrySet.h index e4e0b7373..20c438361 100644 --- a/src/cpp/ripple/LedgerEntrySet.h +++ b/src/cpp/ripple/LedgerEntrySet.h @@ -16,16 +16,18 @@ 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 = 0x40, // Transaction came from a privileged source + tapAFTER_END = 0x40, // We are processing the transaction last + + 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 cedb1be72..27f999c48 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 57d4492ba..5b0df2fed 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 d75ff2366..7df6880d4 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 f64943a03..2d00c2f6a 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/TransactionFormats.cpp b/src/cpp/ripple/TransactionFormats.cpp index 66d3a01e0..ef3b9c0c3 100644 --- a/src/cpp/ripple/TransactionFormats.cpp +++ b/src/cpp/ripple/TransactionFormats.cpp @@ -78,12 +78,11 @@ void TFInit() ; DECLARE_TF(SetFee, ttFEE) - << SOElement(sfFeatures, SOE_REQUIRED) << SOElement(sfBaseFee, SOE_REQUIRED) << SOElement(sfReferenceFeeUnits, SOE_REQUIRED) << SOElement(sfReserveBase, SOE_REQUIRED) << SOElement(sfReserveIncrement, SOE_REQUIRED) - ; + ; } TransactionFormat* TransactionFormat::getTxnFormat(TransactionType t) diff --git a/src/cpp/ripple/Transactor.cpp b/src/cpp/ripple/Transactor.cpp index e3396b205..050ad89b2 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 f530b6f9c..d72bd4b74 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();