Properly handle tec return codes. This won't compile until isTecClaim exists.

This commit is contained in:
JoelKatz
2012-12-23 15:09:10 -08:00
parent 56d97f95d7
commit f95ed4c3f5

View File

@@ -110,13 +110,31 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
cLog(lsINFO) << "applyTransaction: terResult=" << strToken << " : " << terResult << " : " << strHuman; cLog(lsINFO) << "applyTransaction: terResult=" << strToken << " : " << terResult << " : " << strHuman;
if (isTepPartial(terResult) && isSetBit(params, tapRETRY)) bool applyTransaction = false;
{
// Partial result and allowed to retry, reclassify as a retry. if (terResult == tesSUCCESS)
terResult = terRETRY; applyTransaction = true;
else if (isTepPartial(terResult) && !isSetBit(params, tapRETRY))
applyTransaction = true;
else if (isTecClaim(terResult) && !isSetBit(params, tapRETRY))
{ // only claim the transaction fee
mNodes.clear();
SLE::pointer txnAcct = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(txn.getSourceAccount()));
STAmount fee = txn.getTransactionFee();
STAmount balance = txnAcct->getFieldAmount(sfBalance);
if (balance < fee)
terResult = terINSUF_FEE_B;
else
{
txnAcct->setFieldAmount(sfBalance, balance - fee);
applyTransaction = true;
entryModify(txnAcct);
}
} }
if ((tesSUCCESS == terResult) || isTepPartial(terResult)) if (applyTransaction)
{ {
// Transaction succeeded fully or (retries are not allowed and the transaction succeeded partially). // Transaction succeeded fully or (retries are not allowed and the transaction succeeded partially).
Serializer m; Serializer m;