From 72d8811ad38d20f35dd7ca5322b330c060353de0 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Thu, 13 Dec 2012 15:45:49 -0800 Subject: [PATCH] Add and use new owner_reserve. --- src/cpp/ripple/Config.cpp | 16 +++++++++++----- src/cpp/ripple/Config.h | 3 ++- src/cpp/ripple/LedgerFormats.cpp | 1 + src/cpp/ripple/PaymentTransactor.cpp | 14 +++++++++----- src/cpp/ripple/SerializeProto.h | 1 + 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/cpp/ripple/Config.cpp b/src/cpp/ripple/Config.cpp index 88b51c9eb4..4fe97a4b82 100644 --- a/src/cpp/ripple/Config.cpp +++ b/src/cpp/ripple/Config.cpp @@ -17,7 +17,8 @@ #define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create" #define SECTION_FEE_OFFER "fee_offer" #define SECTION_FEE_OPERATION "fee_operation" -#define SECTION_FEE_RESERVE "fee_reserve" +#define SECTION_FEE_ACCOUNT_RESERVE "fee_account_reserve" +#define SECTION_FEE_OWNER_RESERVE "fee_owner_reserve" #define SECTION_LEDGER_HISTORY "ledger_history" #define SECTION_IPS "ips" #define SECTION_NETWORK_QUORUM "network_quorum" @@ -48,7 +49,8 @@ // Fees are in XRP. #define DEFAULT_FEE_DEFAULT 10 -#define DEFAULT_FEE_RESERVE 200*SYSTEM_CURRENCY_PARTS +#define DEFAULT_FEE_ACCOUNT_RESERVE 200*SYSTEM_CURRENCY_PARTS +#define DEFAULT_FEE_OWNER_RESERVE 50*SYSTEM_CURRENCY_PARTS #define DEFAULT_FEE_NICKNAME_CREATE 1000 #define DEFAULT_FEE_OFFER DEFAULT_FEE_DEFAULT #define DEFAULT_FEE_OPERATION 1 @@ -162,7 +164,8 @@ void Config::setup(const std::string& strConf, bool bQuiet) NETWORK_QUORUM = 0; // Don't need to see other nodes VALIDATION_QUORUM = 1; // Only need one node to vouch - FEE_RESERVE = DEFAULT_FEE_RESERVE; + FEE_ACCOUNT_RESERVE = DEFAULT_FEE_ACCOUNT_RESERVE; + FEE_OWNER_RESERVE = DEFAULT_FEE_OWNER_RESERVE; FEE_NICKNAME_CREATE = DEFAULT_FEE_NICKNAME_CREATE; FEE_OFFER = DEFAULT_FEE_OFFER; FEE_DEFAULT = DEFAULT_FEE_DEFAULT; @@ -297,8 +300,11 @@ void Config::load() if (sectionSingleB(secConfig, SECTION_VALIDATION_QUORUM, strTemp)) VALIDATION_QUORUM = std::max(0, boost::lexical_cast(strTemp)); - if (sectionSingleB(secConfig, SECTION_FEE_RESERVE, strTemp)) - FEE_RESERVE = boost::lexical_cast(strTemp); + if (sectionSingleB(secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) + FEE_ACCOUNT_RESERVE = boost::lexical_cast(strTemp); + + if (sectionSingleB(secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) + FEE_OWNER_RESERVE = boost::lexical_cast(strTemp); if (sectionSingleB(secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp)) FEE_NICKNAME_CREATE = boost::lexical_cast(strTemp); diff --git a/src/cpp/ripple/Config.h b/src/cpp/ripple/Config.h index 881fb572e3..570c766bbd 100644 --- a/src/cpp/ripple/Config.h +++ b/src/cpp/ripple/Config.h @@ -108,7 +108,8 @@ public: // Fee schedule uint64 FEE_DEFAULT; // Default fee. - uint64 FEE_RESERVE; // Amount of XRP not allowed to send. + uint64 FEE_ACCOUNT_RESERVE; // Amount of XRP not allowed to send. + uint64 FEE_OWNER_RESERVE; // Amount of XRP not allowed to send per owner entry. uint64 FEE_NICKNAME_CREATE; // Fee to create a nickname. uint64 FEE_OFFER; // Rate per day. int FEE_CONTRACT_OPERATION; // fee for each contract operation diff --git a/src/cpp/ripple/LedgerFormats.cpp b/src/cpp/ripple/LedgerFormats.cpp index 1311a63c84..1e553398aa 100644 --- a/src/cpp/ripple/LedgerFormats.cpp +++ b/src/cpp/ripple/LedgerFormats.cpp @@ -28,6 +28,7 @@ static bool LEFInit() << SOElement(sfMessageKey, SOE_OPTIONAL) << SOElement(sfTransferRate, SOE_OPTIONAL) << SOElement(sfDomain, SOE_OPTIONAL) + << SOElement(sfOwnerCount, SOE_OPTIONAL) ; DECLARE_LEF(Contract, ltCONTRACT) diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index acd0021e9c..8c6f32d021 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -82,8 +82,8 @@ TER PaymentTransactor::doApply() return temCREATEXRP; } - else if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, we can vote. - && saDstAmount.getNValue() < theConfig.FEE_RESERVE) // Reserve is not scaled by fee. + else if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, we can vote. + && saDstAmount.getNValue() < theConfig.FEE_ACCOUNT_RESERVE) // Reserve is not scaled by fee. { Log(lsINFO) << "doPayment: Delay transaction: Destination account does not exist insufficent payment to create account."; @@ -136,11 +136,15 @@ TER PaymentTransactor::doApply() { // Direct XRP payment. - STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance); + const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance); + const uint32 uOwnerCount = mTxn.getFieldU32(sfOwnerCount); + const uint64 uReserve = theConfig.FEE_ACCOUNT_RESERVE+uOwnerCount*theConfig.FEE_OWNER_RESERVE; - if (saSrcXRPBalance < saDstAmount + theConfig.FEE_RESERVE) // Reserve is not scaled by fee. + // Make sure have enough reserve to send. + if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, we can vote. + && saSrcXRPBalance < saDstAmount + uReserve) // Reserve is not scaled by fee. { - // Transaction might succeed, if applied in a different order. + // Vote no. However, transaction might succeed, if applied in a different order. Log(lsINFO) << "doPayment: Delay transaction: Insufficient funds."; terResult = terUNFUNDED; diff --git a/src/cpp/ripple/SerializeProto.h b/src/cpp/ripple/SerializeProto.h index 7c88837d3f..286cf617f7 100644 --- a/src/cpp/ripple/SerializeProto.h +++ b/src/cpp/ripple/SerializeProto.h @@ -43,6 +43,7 @@ FIELD(Expiration, UINT32, 10) FIELD(TransferRate, UINT32, 11) FIELD(WalletSize, UINT32, 12) + FIELD(OwnerCount, UINT32, 13) // Reorder on ledger reset. // 32-bit integers (uncommon) FIELD(HighQualityIn, UINT32, 16)