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

This commit is contained in:
JoelKatz
2013-01-19 14:32:14 -08:00
10 changed files with 117 additions and 30 deletions

View File

@@ -525,6 +525,11 @@ TER LedgerEntrySet::dirAdd(
const uint256& uLedgerIndex,
boost::function<void (SLE::ref)> fDescriber)
{
cLog(lsDEBUG)
<< boost::str(boost::format("dirAdd: uRootIndex=%s uLedgerIndex=%s")
% uRootIndex.ToString()
% uLedgerIndex.ToString());
SLE::pointer sleNode;
STVector256 svIndexes;
SLE::pointer sleRoot = entryCache(ltDIR_NODE, uRootIndex);

View File

@@ -531,10 +531,6 @@ void LedgerMaster::pubThread()
cLog(lsDEBUG) << "Publishing ledger " << l->getLedgerSeq();
setFullLedger(l); // OPTIMIZEME: This is actually more work than we need to do
theApp->getOPs().pubLedger(l);
BOOST_FOREACH(callback& c, mOnValidate)
{
c(l);
}
}
}
}

View File

@@ -229,11 +229,16 @@ TER OfferCreateTransactor::takeOffers(
}
}
cLog(lsINFO) << "takeOffers: " << transToken(terResult);
// On storing meta data, delete offers that were found unfunded to prevent encountering them in future.
if (tesSUCCESS == terResult)
{
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedFound)
{
cLog(lsINFO) << "takeOffers: found unfunded: " << uOfferIndex.ToString();
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
if (tesSUCCESS != terResult)
break;
@@ -245,12 +250,16 @@ TER OfferCreateTransactor::takeOffers(
// On success, delete offers that became unfunded.
BOOST_FOREACH(const uint256& uOfferIndex, usOfferUnfundedBecame)
{
cLog(lsINFO) << "takeOffers: became unfunded: " << uOfferIndex.ToString();
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
if (tesSUCCESS != terResult)
break;
}
}
cLog(lsINFO) << "takeOffers< " << transToken(terResult);
return terResult;
}
@@ -331,7 +340,7 @@ TER OfferCreateTransactor::doApply()
{
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
terResult = tecUNFUNDED;
terResult = tecUNFUNDED_OFFER;
}
if (tesSUCCESS == terResult && !saTakerPays.isNative())

View File

@@ -161,7 +161,7 @@ TER PaymentTransactor::doApply()
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
terResult = tecUNFUNDED;
terResult = tecUNFUNDED_PAYMENT;
}
else
{

View File

@@ -19,7 +19,10 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
{ tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." },
{ tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." },
{ tecUNFUNDED, "tecUNFUNDED", "Source account had insufficient balance for transaction." },
{ tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." },
{ tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." },
{ tecUNFUNDED_OFFER, "tecUNFUNDED_OFFER", "Insufficient balance to fund created offer." },
{ tecUNFUNDED_PAYMENT, "tecUNFUNDED_PAYMENT", "Insufficient XRP balance to send." },
{ tefFAILURE, "tefFAILURE", "Failed to apply." },
{ tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." },

View File

@@ -111,6 +111,9 @@ enum TER // aka TransactionEngineResult
// DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data.
tecCLAIM = 100,
tecPATH_PARTIAL = 101,
tecUNFUNDED_ADD = 102,
tecUNFUNDED_OFFER = 103,
tecUNFUNDED_PAYMENT = 104,
tecDIR_FULL = 121,
tecINSUF_RESERVE_LINE = 122,
tecINSUF_RESERVE_OFFER = 123,
@@ -119,7 +122,7 @@ enum TER // aka TransactionEngineResult
tecNO_LINE_INSUF_RESERVE = 126,
tecNO_LINE_REDUNDANT = 127,
tecPATH_DRY = 128,
tecUNFUNDED = 129,
tecUNFUNDED = 129, // Depericated, old ambiguous unfunded.
};
#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED)

View File

@@ -38,29 +38,33 @@ TER WalletAddTransactor::doApply()
return tefCREATED;
}
STAmount saAmount = mTxn.getFieldAmount(sfAmount);
STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
// Direct XRP payment.
if (saSrcBalance < saAmount)
STAmount saDstAmount = mTxn.getFieldAmount(sfAmount);
const STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
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.
if (saSrcBalance + saPaid < saDstAmount + uReserve) // Reserve is not scaled by fee.
{
std::cerr
<< boost::str(boost::format("WalletAdd: Delay transaction: insufficient balance: balance=%s amount=%s")
% saSrcBalance.getText()
% saAmount.getText())
<< std::endl;
// Vote no. However, transaction might succeed, if applied in a different order.
cLog(lsINFO) << boost::str(boost::format("WalletAdd: Delay transaction: Insufficient funds: %s / %s (%d)")
% saSrcBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
return tecUNFUNDED;
return tecUNFUNDED_ADD;
}
// Deduct initial balance from source account.
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saAmount);
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saDstAmount);
// Create the account.
sleDst = mEngine->entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
sleDst->setFieldAccount(sfAccount, uDstAccountID);
sleDst->setFieldU32(sfSequence, 1);
sleDst->setFieldAmount(sfBalance, saAmount);
sleDst->setFieldAmount(sfBalance, saDstAmount);
sleDst->setFieldAccount(sfRegularKey, uAuthKeyID);
std::cerr << "WalletAdd<" << std::endl;