Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
JoelKatz
2013-02-24 15:13:40 -08:00
5 changed files with 18 additions and 19 deletions

View File

@@ -466,7 +466,7 @@ TER OfferCreateTransactor::doApply()
// Complete as is. // Complete as is.
nothing(); nothing();
} }
else if (mTxnAccount->getFieldAmount(sfBalance).getNValue() < mEngine->getLedger()->getReserve(mTxnAccount->getFieldU32(sfOwnerCount)+1)) else if (mPriorBalance.getNValue() < mEngine->getLedger()->getReserve(mTxnAccount->getFieldU32(sfOwnerCount)+1))
{ {
if (isSetBit(mParams, tapOPEN_LEDGER)) // Ledger is not final, can vote no. if (isSetBit(mParams, tapOPEN_LEDGER)) // Ledger is not final, can vote no.
{ {

View File

@@ -190,24 +190,22 @@ TER PaymentTransactor::doApply()
{ {
// Direct XRP payment. // Direct XRP payment.
const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance);
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount); const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
const uint64 uReserve = mEngine->getLedger()->getReserve(uOwnerCount); const uint64 uReserve = mEngine->getLedger()->getReserve(uOwnerCount);
STAmount saPaid = mTxn.getTransactionFee();
// Make sure have enough reserve to send. Allow final spend to use reserve for fee. // Make sure have enough reserve to send. Allow final spend to use reserve for fee.
if (saSrcXRPBalance + saPaid < saDstAmount + uReserve) // Reserve is not scaled by fee. if (mPriorBalance < saDstAmount + uReserve) // Reserve is not scaled by fee.
{ {
// Vote no. However, transaction might succeed, if applied in a different order. // Vote no. However, transaction might succeed, if applied in a different order.
cLog(lsINFO) << ""; cLog(lsINFO) << "";
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)") cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve); % mPriorBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
terResult = tecUNFUNDED_PAYMENT; terResult = tecUNFUNDED_PAYMENT;
} }
else else
{ {
mTxnAccount->setFieldAmount(sfBalance, saSrcXRPBalance - saDstAmount); mTxnAccount->setFieldAmount(sfBalance, mSourceBalance - saDstAmount);
sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount); sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount);
// re-arm the password change fee if we can and need to // re-arm the password change fee if we can and need to

View File

@@ -202,7 +202,8 @@ TER Transactor::apply()
} }
else else
{ {
mSourceBalance = mTxnAccount->getFieldAmount(sfBalance); mPriorBalance = mTxnAccount->getFieldAmount(sfBalance);
mSourceBalance = mPriorBalance;
mHasAuthKey = mTxnAccount->isFieldPresent(sfRegularKey); mHasAuthKey = mTxnAccount->isFieldPresent(sfRegularKey);
} }

View File

@@ -15,7 +15,8 @@ protected:
uint160 mTxnAccountID; uint160 mTxnAccountID;
STAmount mFeeDue; STAmount mFeeDue;
STAmount mSourceBalance; STAmount mPriorBalance; // Balance before fees.
STAmount mSourceBalance; // Balance after fees.
SLE::pointer mTxnAccount; SLE::pointer mTxnAccount;
bool mHasAuthKey; bool mHasAuthKey;
RippleAddress mSigningPubKey; RippleAddress mSigningPubKey;

View File

@@ -73,7 +73,6 @@ TER TrustSetTransactor::doApply()
return tecNO_DST; return tecNO_DST;
} }
const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance);
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount); const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
// The reserve required to create the line. // The reserve required to create the line.
const uint64 uReserveCreate = mEngine->getLedger()->getReserve(uOwnerCount + 1); const uint64 uReserveCreate = mEngine->getLedger()->getReserve(uOwnerCount + 1);
@@ -263,7 +262,7 @@ TER TrustSetTransactor::doApply()
mEngine->entryDelete(sleRippleState); mEngine->entryDelete(sleRippleState);
} }
else if (bReserveIncrease else if (bReserveIncrease
&& saSrcXRPBalance.getNValue() < uReserveCreate) // Reserve is not scaled by load. && mPriorBalance.getNValue() < uReserveCreate) // Reserve is not scaled by load.
{ {
cLog(lsINFO) << "doTrustSet: Delay transaction: Insufficent reserve to add trust line."; cLog(lsINFO) << "doTrustSet: Delay transaction: Insufficent reserve to add trust line.";
@@ -286,7 +285,7 @@ TER TrustSetTransactor::doApply()
return tecNO_LINE_REDUNDANT; return tecNO_LINE_REDUNDANT;
} }
else if (saSrcXRPBalance.getNValue() < uReserveCreate) // Reserve is not scaled by load. else if (mPriorBalance.getNValue() < uReserveCreate) // Reserve is not scaled by load.
{ {
cLog(lsINFO) << "doTrustSet: Delay transaction: Line does not exist. Insufficent reserve to create line."; cLog(lsINFO) << "doTrustSet: Delay transaction: Line does not exist. Insufficent reserve to create line.";