mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Rename TransactionEngineResult to TER & work on ripple.
This commit is contained in:
@@ -799,7 +799,7 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, const Serializ
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
TransactionEngineResult result = engine.applyTransaction(*txn, parms);
|
TER result = engine.applyTransaction(*txn, parms);
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << " retry";
|
Log(lsINFO) << " retry";
|
||||||
@@ -861,7 +861,7 @@ void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, const Ledger
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TransactionEngineResult result = engine.applyTransaction(*it->second, parms);
|
TER result = engine.applyTransaction(*it->second, parms);
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
if (result == 0) ++successes;
|
if (result == 0) ++successes;
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ Ledger::pointer LedgerMaster::closeLedger()
|
|||||||
return closingLedger;
|
return closingLedger;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult LedgerMaster::doTransaction(const SerializedTransaction& txn, uint32 targetLedger,
|
TER LedgerMaster::doTransaction(const SerializedTransaction& txn, uint32 targetLedger,
|
||||||
TransactionEngineParams params)
|
TransactionEngineParams params)
|
||||||
{
|
{
|
||||||
TransactionEngineResult result = mEngine.applyTransaction(txn, params);
|
TER result = mEngine.applyTransaction(txn, params);
|
||||||
theApp->getOPs().pubTransaction(mEngine.getLedger(), txn, result);
|
theApp->getOPs().pubTransaction(mEngine.getLedger(), txn, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
void runStandAlone() { mFinalizedLedger = mCurrentLedger; }
|
void runStandAlone() { mFinalizedLedger = mCurrentLedger; }
|
||||||
|
|
||||||
TransactionEngineResult doTransaction(const SerializedTransaction& txn, uint32 targetLedger,
|
TER doTransaction(const SerializedTransaction& txn, uint32 targetLedger,
|
||||||
TransactionEngineParams params);
|
TransactionEngineParams params);
|
||||||
|
|
||||||
void pushLedger(const Ledger::pointer& newLedger);
|
void pushLedger(const Ledger::pointer& newLedger);
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
|
|||||||
return trans;
|
return trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tgtLedger, tepNONE);
|
TER r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tgtLedger, tepNONE);
|
||||||
if (r == tefFAILURE) throw Fault(IO_ERROR);
|
if (r == tefFAILURE) throw Fault(IO_ERROR);
|
||||||
|
|
||||||
if (r == terPRE_SEQ)
|
if (r == terPRE_SEQ)
|
||||||
@@ -875,7 +875,7 @@ void NetworkOPs::pubLedger(const Ledger::pointer& lpAccepted)
|
|||||||
SerializedTransaction::pointer stTxn = theApp->getMasterTransaction().fetch(item, false, 0);
|
SerializedTransaction::pointer stTxn = theApp->getMasterTransaction().fetch(item, false, 0);
|
||||||
// XXX Need to support other results.
|
// XXX Need to support other results.
|
||||||
// XXX Need to give failures too.
|
// XXX Need to give failures too.
|
||||||
TransactionEngineResult terResult = tesSUCCESS;
|
TER terResult = tesSUCCESS;
|
||||||
|
|
||||||
if (bAll)
|
if (bAll)
|
||||||
{
|
{
|
||||||
@@ -909,7 +909,7 @@ void NetworkOPs::pubLedger(const Ledger::pointer& lpAccepted)
|
|||||||
// XXX Publish delta information for accounts.
|
// XXX Publish delta information for accounts.
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TransactionEngineResult terResult, const std::string& strStatus, int iSeq, const std::string& strType)
|
Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, TER terResult, const std::string& strStatus, int iSeq, const std::string& strType)
|
||||||
{
|
{
|
||||||
Json::Value jvObj(Json::objectValue);
|
Json::Value jvObj(Json::objectValue);
|
||||||
std::string strToken;
|
std::string strToken;
|
||||||
@@ -927,7 +927,7 @@ Json::Value NetworkOPs::transJson(const SerializedTransaction& stTxn, Transactio
|
|||||||
return jvObj;
|
return jvObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkOPs::pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState)
|
void NetworkOPs::pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||||
{
|
{
|
||||||
Json::Value jvObj = transJson(stTxn, terResult, pState, lpCurrent->getLedgerSeq(), "transaction");
|
Json::Value jvObj = transJson(stTxn, terResult, pState, lpCurrent->getLedgerSeq(), "transaction");
|
||||||
|
|
||||||
@@ -937,7 +937,7 @@ void NetworkOPs::pubTransactionAll(const Ledger::pointer& lpCurrent, const Seria
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkOPs::pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState)
|
void NetworkOPs::pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState)
|
||||||
{
|
{
|
||||||
boost::unordered_set<InfoSub*> usisNotify;
|
boost::unordered_set<InfoSub*> usisNotify;
|
||||||
|
|
||||||
@@ -972,7 +972,7 @@ void NetworkOPs::pubTransactionAccounts(const Ledger::pointer& lpCurrent, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkOPs::pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult)
|
void NetworkOPs::pubTransaction(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult)
|
||||||
{
|
{
|
||||||
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
boost::interprocess::sharable_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ protected:
|
|||||||
|
|
||||||
void setMode(OperatingMode);
|
void setMode(OperatingMode);
|
||||||
|
|
||||||
Json::Value transJson(const SerializedTransaction& stTxn, TransactionEngineResult terResult, const std::string& strStatus, int iSeq, const std::string& strType);
|
Json::Value transJson(const SerializedTransaction& stTxn, TER terResult, const std::string& strStatus, int iSeq, const std::string& strType);
|
||||||
void pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState);
|
void pubTransactionAll(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||||
void pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TransactionEngineResult terResult, const char* pState);
|
void pubTransactionAccounts(const Ledger::pointer& lpCurrent, const SerializedTransaction& stTxn, TER terResult, const char* pState);
|
||||||
|
|
||||||
Json::Value pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID);
|
Json::Value pubBootstrapAccountInfo(const Ledger::pointer& lpAccepted, const NewcoinAddress& naAccountID);
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ public:
|
|||||||
|
|
||||||
void pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj);
|
void pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj);
|
||||||
void pubLedger(const Ledger::pointer& lpAccepted);
|
void pubLedger(const Ledger::pointer& lpAccepted);
|
||||||
void pubTransaction(const Ledger::pointer& lpLedger, const SerializedTransaction& stTxn, TransactionEngineResult terResult);
|
void pubTransaction(const Ledger::pointer& lpLedger, const SerializedTransaction& stTxn, TER terResult);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Monitoring: subscriber side
|
// Monitoring: subscriber side
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ std::size_t hash_value(const aciSource& asValue)
|
|||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool transResultInfo(TransactionEngineResult terCode, std::string& strToken, std::string& strHuman)
|
bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
|
||||||
{
|
{
|
||||||
static struct {
|
static struct {
|
||||||
TransactionEngineResult terCode;
|
TER terCode;
|
||||||
const char* cpToken;
|
const char* cpToken;
|
||||||
const char* cpHuman;
|
const char* cpHuman;
|
||||||
} transResultInfoA[] = {
|
} transResultInfoA[] = {
|
||||||
@@ -430,10 +430,10 @@ STAmount TransactionEngine::accountSend(const uint160& uSenderID, const uint160&
|
|||||||
return saActualCost;
|
return saActualCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID)
|
TER TransactionEngine::offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID)
|
||||||
{
|
{
|
||||||
uint64 uOwnerNode = sleOffer->getIFieldU64(sfOwnerNode);
|
uint64 uOwnerNode = sleOffer->getIFieldU64(sfOwnerNode);
|
||||||
TransactionEngineResult terResult = dirDelete(false, uOwnerNode, Ledger::getOwnerDirIndex(uOwnerID), uOfferIndex, false);
|
TER terResult = dirDelete(false, uOwnerNode, Ledger::getOwnerDirIndex(uOwnerID), uOfferIndex, false);
|
||||||
|
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
{
|
{
|
||||||
@@ -448,7 +448,7 @@ TransactionEngineResult TransactionEngine::offerDelete(const SLE::pointer& sleOf
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::offerDelete(const uint256& uOfferIndex)
|
TER TransactionEngine::offerDelete(const uint256& uOfferIndex)
|
||||||
{
|
{
|
||||||
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||||
const uint160 uOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
const uint160 uOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||||
@@ -461,7 +461,7 @@ TransactionEngineResult TransactionEngine::offerDelete(const uint256& uOfferInde
|
|||||||
// --> uLedgerIndex: Value to add to directory.
|
// --> uLedgerIndex: Value to add to directory.
|
||||||
// We only append. This allow for things that watch append only structure to just monitor from the last node on ward.
|
// We only append. This allow for things that watch append only structure to just monitor from the last node on ward.
|
||||||
// Within a node with no deletions order of elements is sequential. Otherwise, order of elements is random.
|
// Within a node with no deletions order of elements is sequential. Otherwise, order of elements is random.
|
||||||
TransactionEngineResult TransactionEngine::dirAdd(
|
TER TransactionEngine::dirAdd(
|
||||||
uint64& uNodeDir,
|
uint64& uNodeDir,
|
||||||
const uint256& uRootIndex,
|
const uint256& uRootIndex,
|
||||||
const uint256& uLedgerIndex)
|
const uint256& uLedgerIndex)
|
||||||
@@ -550,7 +550,7 @@ TransactionEngineResult TransactionEngine::dirAdd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ledger must be in a state for this to work.
|
// Ledger must be in a state for this to work.
|
||||||
TransactionEngineResult TransactionEngine::dirDelete(
|
TER TransactionEngine::dirDelete(
|
||||||
const bool bKeepRoot, // --> True, if we never completely clean up, after we overflow the root node.
|
const bool bKeepRoot, // --> True, if we never completely clean up, after we overflow the root node.
|
||||||
const uint64& uNodeDir, // --> Node containing entry.
|
const uint64& uNodeDir, // --> Node containing entry.
|
||||||
const uint256& uRootIndex, // --> The index of the base of the directory. Nodes are based off of this.
|
const uint256& uRootIndex, // --> The index of the base of the directory. Nodes are based off of this.
|
||||||
@@ -778,7 +778,7 @@ bool TransactionEngine::dirNext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the authorized public key for an account. May also set the generator map.
|
// Set the authorized public key for an account. May also set the generator map.
|
||||||
TransactionEngineResult TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMustSetGenerator)
|
TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMustSetGenerator)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Verify that submitter knows the private key for the generator.
|
// Verify that submitter knows the private key for the generator.
|
||||||
@@ -918,7 +918,7 @@ void TransactionEngine::txnWrite()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTransaction& txn,
|
TER TransactionEngine::applyTransaction(const SerializedTransaction& txn,
|
||||||
TransactionEngineParams params)
|
TransactionEngineParams params)
|
||||||
{
|
{
|
||||||
Log(lsTRACE) << "applyTransaction>";
|
Log(lsTRACE) << "applyTransaction>";
|
||||||
@@ -944,8 +944,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TransactionEngineResult terResult = tesSUCCESS;
|
TER terResult = tesSUCCESS;
|
||||||
|
|
||||||
uint256 txID = txn.getTransactionID();
|
uint256 txID = txn.getTransactionID();
|
||||||
if (!txID)
|
if (!txID)
|
||||||
{
|
{
|
||||||
@@ -1329,7 +1328,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doAccountSet>";
|
Log(lsINFO) << "doAccountSet>";
|
||||||
|
|
||||||
@@ -1475,20 +1474,20 @@ TransactionEngineResult TransactionEngine::doAccountSet(const SerializedTransact
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction& txn)
|
TER TransactionEngine::doClaim(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doClaim>";
|
Log(lsINFO) << "doClaim>";
|
||||||
|
|
||||||
TransactionEngineResult terResult = setAuthorized(txn, true);
|
TER terResult = setAuthorized(txn, true);
|
||||||
|
|
||||||
Log(lsINFO) << "doClaim<";
|
Log(lsINFO) << "doClaim<";
|
||||||
|
|
||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
TransactionEngineResult terResult = tesSUCCESS;
|
TER terResult = tesSUCCESS;
|
||||||
Log(lsINFO) << "doCreditSet>";
|
Log(lsINFO) << "doCreditSet>";
|
||||||
|
|
||||||
// Check if destination makes sense.
|
// Check if destination makes sense.
|
||||||
@@ -1626,7 +1625,7 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doNicknameSet(const SerializedTransaction& txn)
|
TER TransactionEngine::doNicknameSet(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "doNicknameSet>" << std::endl;
|
std::cerr << "doNicknameSet>" << std::endl;
|
||||||
|
|
||||||
@@ -1672,7 +1671,7 @@ TransactionEngineResult TransactionEngine::doNicknameSet(const SerializedTransac
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doPasswordFund(const SerializedTransaction& txn)
|
TER TransactionEngine::doPasswordFund(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "doPasswordFund>" << std::endl;
|
std::cerr << "doPasswordFund>" << std::endl;
|
||||||
|
|
||||||
@@ -1706,7 +1705,7 @@ TransactionEngineResult TransactionEngine::doPasswordFund(const SerializedTransa
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doPasswordSet(const SerializedTransaction& txn)
|
TER TransactionEngine::doPasswordSet(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "doPasswordSet>" << std::endl;
|
std::cerr << "doPasswordSet>" << std::endl;
|
||||||
|
|
||||||
@@ -1719,7 +1718,7 @@ TransactionEngineResult TransactionEngine::doPasswordSet(const SerializedTransac
|
|||||||
|
|
||||||
mTxnAccount->setFlag(lsfPasswordSpent);
|
mTxnAccount->setFlag(lsfPasswordSpent);
|
||||||
|
|
||||||
TransactionEngineResult terResult = setAuthorized(txn, false);
|
TER terResult = setAuthorized(txn, false);
|
||||||
|
|
||||||
std::cerr << "doPasswordSet<" << std::endl;
|
std::cerr << "doPasswordSet<" << std::endl;
|
||||||
|
|
||||||
@@ -1739,9 +1738,9 @@ TransactionEngineResult TransactionEngine::doPasswordSet(const SerializedTransac
|
|||||||
// <-- terResult : tesSUCCESS = no error and if !bAllowPartial complelely satisfied wanted.
|
// <-- terResult : tesSUCCESS = no error and if !bAllowPartial complelely satisfied wanted.
|
||||||
// <-> usOffersDeleteAlways:
|
// <-> usOffersDeleteAlways:
|
||||||
// <-> usOffersDeleteOnSuccess:
|
// <-> usOffersDeleteOnSuccess:
|
||||||
TransactionEngineResult calcOfferFill(paymentNode& pnSrc, paymentNode& pnDst, bool bAllowPartial)
|
TER calcOfferFill(paymentNode& pnSrc, paymentNode& pnDst, bool bAllowPartial)
|
||||||
{
|
{
|
||||||
TransactionEngineResult terResult;
|
TER terResult;
|
||||||
|
|
||||||
if (pnDst.saWanted.isNative())
|
if (pnDst.saWanted.isNative())
|
||||||
{
|
{
|
||||||
@@ -1897,13 +1896,12 @@ void TransactionEngine::calcOfferBridgeNext(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// <-- bSuccess: false= no transfer
|
TER TransactionEngine::calcNodeOfferRev(
|
||||||
bool TransactionEngine::calcNodeOfferRev(
|
|
||||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||||
const PathState::pointer& pspCur,
|
const PathState::pointer& pspCur,
|
||||||
const bool bMultiQuality)
|
const bool bMultiQuality)
|
||||||
{
|
{
|
||||||
bool bSuccess = false;
|
TER terResult = tepPATH_DRY;
|
||||||
|
|
||||||
paymentNode& pnPrv = pspCur->vpnNodes[uIndex-1];
|
paymentNode& pnPrv = pspCur->vpnNodes[uIndex-1];
|
||||||
paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
||||||
@@ -1964,65 +1962,77 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
SLE::pointer sleDirectDir = entryCache(ltDIR_NODE, uDirectTip);
|
SLE::pointer sleDirectDir = entryCache(ltDIR_NODE, uDirectTip);
|
||||||
const STAmount saOfrRate = STAmount::setRate(Ledger::getQuality(uDirectTip)); // For correct ratio
|
const STAmount saOfrRate = STAmount::setRate(Ledger::getQuality(uDirectTip)); // For correct ratio
|
||||||
unsigned int uEntry = 0;
|
unsigned int uEntry = 0;
|
||||||
uint256 uCurIndex;
|
uint256 uOfferIndex;
|
||||||
|
|
||||||
while (saCurDlvReq != saCurDlvAct // Have not met request.
|
while (saCurDlvReq != saCurDlvAct // Have not met request.
|
||||||
&& dirNext(uDirectTip, sleDirectDir, uEntry, uCurIndex))
|
&& dirNext(uDirectTip, sleDirectDir, uEntry, uOfferIndex))
|
||||||
{
|
{
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNodeOfferRev: uCurIndex=%s") % uCurIndex.ToString());
|
Log(lsINFO) << boost::str(boost::format("calcNodeOfferRev: uOfferIndex=%s") % uOfferIndex.ToString());
|
||||||
|
|
||||||
SLE::pointer sleCurOfr = entryCache(ltOFFER, uCurIndex);
|
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||||
|
|
||||||
if (sleCurOfr->getIFieldPresent(sfExpiration) && sleCurOfr->getIFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
if (sleOffer->getIFieldPresent(sfExpiration) && sleOffer->getIFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
||||||
{
|
{
|
||||||
// Offer is expired.
|
// Offer is expired.
|
||||||
Log(lsINFO) << "calcNodeOfferRev: encountered expired offer";
|
Log(lsINFO) << "calcNodeOfferRev: encountered expired offer";
|
||||||
|
|
||||||
musUnfundedFound.insert(uCurIndex); // Mark offer for always deletion.
|
musUnfundedFound.insert(uOfferIndex); // Mark offer for always deletion.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint160 uCurOfrAccountID = sleCurOfr->getIValueFieldAccount(sfAccount).getAccountID();
|
const uint160 uCurOfrAccountID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||||
const aciSource asLine = boost::make_tuple(uCurOfrAccountID, uCurCurrencyID, uCurIssuerID);
|
const aciSource asLine = boost::make_tuple(uCurOfrAccountID, uCurCurrencyID, uCurIssuerID);
|
||||||
|
|
||||||
// Allowed to access source from this node?
|
// Allowed to access source from this node?
|
||||||
curIssuerNodeConstIterator it = pspCur->umReverse.find(asLine);
|
curIssuerNodeConstIterator itAllow = pspCur->umForward.find(asLine);
|
||||||
|
bool bFoundForward = itAllow != pspCur->umForward.end();
|
||||||
|
|
||||||
if (it == pspCur->umReverse.end())
|
if (bFoundForward || itAllow->second != uIndex)
|
||||||
{
|
{
|
||||||
// Temporarily unfunded. ignore in this column.
|
// Temporarily unfunded. Another node uses this source, ignore in this node.
|
||||||
|
|
||||||
nothing();
|
nothing();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STAmount& saCurOfrOutReq = sleCurOfr->getIValueFieldAmount(sfTakerGets);
|
const STAmount& saCurOfrOutReq = sleOffer->getIValueFieldAmount(sfTakerGets);
|
||||||
// UNUSED? const STAmount& saCurOfrIn = sleCurOfr->getIValueFieldAmount(sfTakerPays);
|
// UNUSED? const STAmount& saCurOfrIn = sleOffer->getIValueFieldAmount(sfTakerPays);
|
||||||
|
|
||||||
STAmount saCurOfrFunds = accountFunds(uCurOfrAccountID, saCurOfrOutReq); // Funds left.
|
STAmount saCurOfrFunds = accountFunds(uCurOfrAccountID, saCurOfrOutReq); // Funds left.
|
||||||
|
|
||||||
|
curIssuerNodeConstIterator itSourcePast = mumSource.find(asLine);
|
||||||
|
bool bFoundPast = itSourcePast != mumSource.end();
|
||||||
|
|
||||||
if (!saCurOfrFunds)
|
if (!saCurOfrFunds)
|
||||||
{
|
{
|
||||||
// Offer is unfunded.
|
// Offer is unfunded.
|
||||||
Log(lsINFO) << "calcNodeOfferRev: encountered unfunded offer";
|
Log(lsINFO) << "calcNodeOfferRev: encountered unfunded offer";
|
||||||
|
|
||||||
curIssuerNodeConstIterator itSource = mumSource.find(asLine);
|
curIssuerNodeConstIterator itSourceCur = bFoundPast
|
||||||
if (itSource == mumSource.end())
|
? pspCur->umReverse.end()
|
||||||
|
: pspCur->umReverse.find(asLine);
|
||||||
|
bool bFoundReverse = itSourceCur != pspCur->umReverse.end();
|
||||||
|
|
||||||
|
if (!bFoundReverse && !bFoundPast)
|
||||||
{
|
{
|
||||||
// Never mentioned before: found unfunded.
|
// Never mentioned before: found unfunded.
|
||||||
musUnfundedFound.insert(uCurIndex); // Mark offer for always deletion.
|
musUnfundedFound.insert(uOfferIndex); // Mark offer for always deletion.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mentioned before: source became unfunded.
|
// Mentioned before: source became unfunded.
|
||||||
pspCur->vUnfundedBecame.push_back(uCurIndex); // Mark offer for deletion on use.
|
pspCur->vUnfundedBecame.push_back(uOfferIndex); // Mark offer for deletion on use of current path state.
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bMentioned = false;
|
||||||
|
|
||||||
if (!!uNxtAccountID)
|
if (!!uNxtAccountID)
|
||||||
{
|
{
|
||||||
// Next is an account.
|
// Next is an account.
|
||||||
|
// Next is redeeming it's own IOUs - no quality.
|
||||||
|
// Offer is paying out IOUs via offer - no quality.
|
||||||
|
|
||||||
STAmount saFeeRate = uCurOfrAccountID == uCurIssuerID || uNxtAccountID == uCurIssuerID
|
STAmount saFeeRate = uCurOfrAccountID == uCurIssuerID || uNxtAccountID == uCurIssuerID
|
||||||
? saOne
|
? saOne
|
||||||
@@ -2042,6 +2052,9 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
|
|
||||||
saCurDlvAct += saOutDlvAct; // Portion of driver served.
|
saCurDlvAct += saOutDlvAct; // Portion of driver served.
|
||||||
saPrvDlvAct += saInDlvAct; // Portion needed in previous.
|
saPrvDlvAct += saInDlvAct; // Portion needed in previous.
|
||||||
|
|
||||||
|
if (!bMentioned)
|
||||||
|
bMentioned = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2067,6 +2080,9 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
{
|
{
|
||||||
// Do a directory.
|
// Do a directory.
|
||||||
// - Drive on computing saCurDlvAct to derive saPrvDlvAct.
|
// - Drive on computing saCurDlvAct to derive saPrvDlvAct.
|
||||||
|
// Although the fee varies based upon the next offer it does not matter as the offer maker knows in
|
||||||
|
// advance that they are obligated to pay a transfer fee of necessary. The owner of next offer has no
|
||||||
|
// expectation of a quality in being applied.
|
||||||
SLE::pointer sleNxtDir = entryCache(ltDIR_NODE, uNxtTip);
|
SLE::pointer sleNxtDir = entryCache(ltDIR_NODE, uNxtTip);
|
||||||
// ??? STAmount saOfrRate = STAmount::setRate(STAmount::getQuality(uNxtTip), uCurCurrencyID); // For correct ratio
|
// ??? STAmount saOfrRate = STAmount::setRate(STAmount::getQuality(uNxtTip), uCurCurrencyID); // For correct ratio
|
||||||
unsigned int uEntry = 0;
|
unsigned int uEntry = 0;
|
||||||
@@ -2080,6 +2096,24 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
uint160 uNxtOfrAccountID = sleNxtOfr->getIValueFieldAccount(sfAccount).getAccountID();
|
uint160 uNxtOfrAccountID = sleNxtOfr->getIValueFieldAccount(sfAccount).getAccountID();
|
||||||
const STAmount& saNxtOfrIn = sleNxtOfr->getIValueFieldAmount(sfTakerPays);
|
const STAmount& saNxtOfrIn = sleNxtOfr->getIValueFieldAmount(sfTakerPays);
|
||||||
|
|
||||||
|
const aciSource asLineNxt = boost::make_tuple(uNxtOfrAccountID, uNxtCurrencyID, uNxtIssuerID);
|
||||||
|
|
||||||
|
// Allowed to access source from this node?
|
||||||
|
curIssuerNodeConstIterator itAllowNxt = pspCur->umForward.find(asLineNxt);
|
||||||
|
curIssuerNodeConstIterator itNxt = itAllowNxt == pspCur->umForward.end()
|
||||||
|
? mumSource.find(asLine)
|
||||||
|
: itAllowNxt;
|
||||||
|
|
||||||
|
assert(itNxt != mumSource.end());
|
||||||
|
|
||||||
|
if (uIndex+1 != itNxt->second)
|
||||||
|
{
|
||||||
|
// Temporarily unfunded. Another node uses this source, ignore in this node.
|
||||||
|
|
||||||
|
nothing();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
STAmount saFeeRate = uCurOfrAccountID == uCurIssuerID || uNxtOfrAccountID == uCurIssuerID
|
STAmount saFeeRate = uCurOfrAccountID == uCurIssuerID || uNxtOfrAccountID == uCurIssuerID
|
||||||
? saOne
|
? saOne
|
||||||
: saTransferRate;
|
: saTransferRate;
|
||||||
@@ -2100,6 +2134,8 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
|
|
||||||
saCurDlvAct += saOutDlvAct; // Portion of driver served.
|
saCurDlvAct += saOutDlvAct; // Portion of driver served.
|
||||||
saPrvDlvAct += saInDlvAct; // Portion needed in previous.
|
saPrvDlvAct += saInDlvAct; // Portion needed in previous.
|
||||||
|
if (!bMentioned)
|
||||||
|
bMentioned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2108,6 +2144,14 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
uNxtTip = 0;
|
uNxtTip = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bMentioned // Need to remember reverse mention.
|
||||||
|
&& !bFoundPast // Not mentioned in previous passes.
|
||||||
|
&& !bFoundForward) // Not mentioned for pass.
|
||||||
|
{
|
||||||
|
// Consider source mentioned by current path state.
|
||||||
|
pspCur->umReverse.insert(std::make_pair(asLine, uIndex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2119,24 +2163,24 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
if (saPrvDlvAct)
|
if (saPrvDlvAct)
|
||||||
{
|
{
|
||||||
saPrvDlvReq = saPrvDlvAct; // Adjust request.
|
saPrvDlvReq = saPrvDlvAct; // Adjust request.
|
||||||
bSuccess = true;
|
terResult = tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNodeOfferRev< uIndex=%d saPrvDlvReq=%s bSuccess=%d")
|
Log(lsINFO) << boost::str(boost::format("calcNodeOfferRev< uIndex=%d saPrvDlvReq=%s terResult=%d")
|
||||||
% uIndex
|
% uIndex
|
||||||
% saPrvDlvReq.getFullText()
|
% saPrvDlvReq.getFullText()
|
||||||
% bSuccess);
|
% terResult);
|
||||||
|
|
||||||
return bSuccess;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TransactionEngine::calcNodeOfferFwd(
|
TER TransactionEngine::calcNodeOfferFwd(
|
||||||
const unsigned int uIndex, // 0 < uIndex < uLast
|
const unsigned int uIndex, // 0 < uIndex < uLast
|
||||||
const PathState::pointer& pspCur,
|
const PathState::pointer& pspCur,
|
||||||
const bool bMultiQuality
|
const bool bMultiQuality
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool bSuccess = false;
|
TER terResult = tepPATH_DRY;
|
||||||
|
|
||||||
paymentNode& pnPrv = pspCur->vpnNodes[uIndex-1];
|
paymentNode& pnPrv = pspCur->vpnNodes[uIndex-1];
|
||||||
paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
||||||
@@ -2330,10 +2374,10 @@ bool TransactionEngine::calcNodeOfferFwd(
|
|||||||
if (saCurDlvAct)
|
if (saCurDlvAct)
|
||||||
{
|
{
|
||||||
saCurDlvReq = saCurDlvAct; // Adjust request.
|
saCurDlvReq = saCurDlvAct; // Adjust request.
|
||||||
bSuccess = true;
|
terResult = tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bSuccess;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -2370,7 +2414,7 @@ void TransactionEngine::calcNodeOffer(
|
|||||||
STAmount& saGot
|
STAmount& saGot
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
TransactionEngineResult terResult = temUNKNOWN;
|
TER terResult = temUNKNOWN;
|
||||||
|
|
||||||
// Direct: not bridging via XNS
|
// Direct: not bridging via XNS
|
||||||
bool bDirectNext = true; // True, if need to load.
|
bool bDirectNext = true; // True, if need to load.
|
||||||
@@ -2652,9 +2696,10 @@ Log(lsINFO) << boost::str(boost::format("calcNodeRipple:4: saCurReq=%s") % saCur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver;
|
// Calculate saPrvRedeemReq, saPrvIssueReq, saPrvDeliver;
|
||||||
bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
// <-- tesSUCCESS or tepPATH_DRY
|
||||||
|
TER TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
||||||
{
|
{
|
||||||
bool bSuccess = true;
|
TER terResult = tesSUCCESS;
|
||||||
const unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
const unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
||||||
|
|
||||||
paymentNode& pnPrv = pspCur->vpnNodes[uIndex ? uIndex-1 : 0];
|
paymentNode& pnPrv = pspCur->vpnNodes[uIndex ? uIndex-1 : 0];
|
||||||
@@ -2772,8 +2817,7 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saCurWantedAct)
|
if (!saCurWantedAct)
|
||||||
{
|
{
|
||||||
// Must have processed something.
|
// Must have processed something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2833,8 +2877,7 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saCurRedeemAct && !saCurIssueAct)
|
if (!saCurRedeemAct && !saCurIssueAct)
|
||||||
{
|
{
|
||||||
// Must want something.
|
// Must want something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNodeAccountRev: ^|account --> ACCOUNT --> account : bPrvRedeem=%d bPrvIssue=%d bRedeem=%d bIssue=%d saCurRedeemReq=%s saCurIssueReq=%s saPrvOwed=%s saCurRedeemAct=%s saCurIssueAct=%s")
|
Log(lsINFO) << boost::str(boost::format("calcNodeAccountRev: ^|account --> ACCOUNT --> account : bPrvRedeem=%d bPrvIssue=%d bRedeem=%d bIssue=%d saCurRedeemReq=%s saCurIssueReq=%s saPrvOwed=%s saCurRedeemAct=%s saCurIssueAct=%s")
|
||||||
@@ -2879,8 +2922,7 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saCurDeliverAct)
|
if (!saCurDeliverAct)
|
||||||
{
|
{
|
||||||
// Must want something.
|
// Must want something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNodeAccountRev: bPrvRedeem=%d bPrvIssue=%d bRedeem=%d bIssue=%d saCurDeliverReq=%s saCurDeliverAct=%s saPrvOwed=%s")
|
Log(lsINFO) << boost::str(boost::format("calcNodeAccountRev: bPrvRedeem=%d bPrvIssue=%d bRedeem=%d bIssue=%d saCurDeliverReq=%s saCurDeliverAct=%s saPrvOwed=%s")
|
||||||
@@ -2911,8 +2953,7 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saCurWantedAct)
|
if (!saCurWantedAct)
|
||||||
{
|
{
|
||||||
// Must have processed something.
|
// Must have processed something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2949,8 +2990,7 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saPrvDeliverAct)
|
if (!saPrvDeliverAct)
|
||||||
{
|
{
|
||||||
// Must want something.
|
// Must want something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2970,13 +3010,11 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
if (!saCurDeliverAct)
|
if (!saCurDeliverAct)
|
||||||
{
|
{
|
||||||
// Must want something.
|
// Must want something.
|
||||||
// terResult = temBAD_AMOUNT;
|
terResult = tepPATH_DRY;
|
||||||
bSuccess = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Need a more nuanced return: temporary fail vs perm?
|
return terResult;
|
||||||
return bSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The previous node: specifies what to push through to current.
|
// The previous node: specifies what to push through to current.
|
||||||
@@ -2984,12 +3022,12 @@ bool TransactionEngine::calcNodeAccountRev(const unsigned int uIndex, const Path
|
|||||||
// The current node: specify what to push through to next.
|
// The current node: specify what to push through to next.
|
||||||
// - Output to next node minus fees.
|
// - Output to next node minus fees.
|
||||||
// Perform balance adjustment with previous.
|
// Perform balance adjustment with previous.
|
||||||
bool TransactionEngine::calcNodeAccountFwd(
|
TER TransactionEngine::calcNodeAccountFwd(
|
||||||
const unsigned int uIndex, // 0 <= uIndex <= uLast
|
const unsigned int uIndex, // 0 <= uIndex <= uLast
|
||||||
const PathState::pointer& pspCur,
|
const PathState::pointer& pspCur,
|
||||||
const bool bMultiQuality)
|
const bool bMultiQuality)
|
||||||
{
|
{
|
||||||
bool bSuccess = true;
|
TER terResult = tesSUCCESS;
|
||||||
const unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
const unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
||||||
|
|
||||||
paymentNode& pnPrv = pspCur->vpnNodes[uIndex ? uIndex-1 : 0];
|
paymentNode& pnPrv = pspCur->vpnNodes[uIndex ? uIndex-1 : 0];
|
||||||
@@ -3250,7 +3288,7 @@ bool TransactionEngine::calcNodeAccountFwd(
|
|||||||
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
||||||
}
|
}
|
||||||
|
|
||||||
return bSuccess;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true, iff lhs has less priority than rhs.
|
// Return true, iff lhs has less priority than rhs.
|
||||||
@@ -3640,43 +3678,42 @@ Json::Value PathState::getJson() const
|
|||||||
// Calculate a node and its previous nodes.
|
// Calculate a node and its previous nodes.
|
||||||
// From the destination work in reverse towards the source calculating how much must be asked for.
|
// From the destination work in reverse towards the source calculating how much must be asked for.
|
||||||
// Then work forward, figuring out how much can actually be delivered.
|
// Then work forward, figuring out how much can actually be delivered.
|
||||||
// --> bAllowPartial: If false, fail if can't meet requirements.
|
// <-- terResult: tesSUCCESS or tepPATH_DRY
|
||||||
// <-- bValid: true=success, false=insufficient funds / liqudity.
|
|
||||||
// <-> pnNodes:
|
// <-> pnNodes:
|
||||||
// --> [end]saWanted.mAmount
|
// --> [end]saWanted.mAmount
|
||||||
// --> [all]saWanted.mCurrency
|
// --> [all]saWanted.mCurrency
|
||||||
// --> [all]saAccount
|
// --> [all]saAccount
|
||||||
// <-> [0]saWanted.mAmount : --> limit, <-- actual
|
// <-> [0]saWanted.mAmount : --> limit, <-- actual
|
||||||
bool TransactionEngine::calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
TER TransactionEngine::calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality)
|
||||||
{
|
{
|
||||||
const paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
const paymentNode& pnCur = pspCur->vpnNodes[uIndex];
|
||||||
const bool bCurAccount = !!(pnCur.uFlags & STPathElement::typeAccount);
|
const bool bCurAccount = !!(pnCur.uFlags & STPathElement::typeAccount);
|
||||||
bool bValid;
|
TER terResult;
|
||||||
|
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNode> uIndex=%d") % uIndex);
|
Log(lsINFO) << boost::str(boost::format("calcNode> uIndex=%d") % uIndex);
|
||||||
|
|
||||||
// Do current node reverse.
|
// Do current node reverse.
|
||||||
bValid = bCurAccount
|
terResult = bCurAccount
|
||||||
? calcNodeAccountRev(uIndex, pspCur, bMultiQuality)
|
? calcNodeAccountRev(uIndex, pspCur, bMultiQuality)
|
||||||
: calcNodeOfferRev(uIndex, pspCur, bMultiQuality);
|
: calcNodeOfferRev(uIndex, pspCur, bMultiQuality);
|
||||||
|
|
||||||
// Do previous.
|
// Do previous.
|
||||||
if (bValid && uIndex)
|
if (tesSUCCESS == terResult && uIndex)
|
||||||
{
|
{
|
||||||
bValid = calcNode(uIndex-1, pspCur, bMultiQuality);
|
terResult = calcNode(uIndex-1, pspCur, bMultiQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do current node forward.
|
// Do current node forward.
|
||||||
if (bValid)
|
if (tesSUCCESS == terResult)
|
||||||
{
|
{
|
||||||
bValid = bCurAccount
|
terResult = bCurAccount
|
||||||
? calcNodeAccountFwd(uIndex, pspCur, bMultiQuality)
|
? calcNodeAccountFwd(uIndex, pspCur, bMultiQuality)
|
||||||
: calcNodeOfferFwd(uIndex, pspCur, bMultiQuality);
|
: calcNodeOfferFwd(uIndex, pspCur, bMultiQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << boost::str(boost::format("calcNode< uIndex=%d bValid=%d") % uIndex % bValid);
|
Log(lsINFO) << boost::str(boost::format("calcNode< uIndex=%d terResult=%d") % uIndex % terResult);
|
||||||
|
|
||||||
return bValid;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the next increment of a path.
|
// Calculate the next increment of a path.
|
||||||
@@ -3711,7 +3748,7 @@ void TransactionEngine::pathNext(const PathState::pointer& pspCur, const int iPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX Need to audit for things like setting accountID not having memory.
|
// XXX Need to audit for things like setting accountID not having memory.
|
||||||
TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction& txn)
|
TER TransactionEngine::doPayment(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
// Ripple if source or destination is non-native or if there are paths.
|
// Ripple if source or destination is non-native or if there are paths.
|
||||||
const uint32 uTxFlags = txn.getFlags();
|
const uint32 uTxFlags = txn.getFlags();
|
||||||
@@ -3876,7 +3913,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
|||||||
vpsPaths.push_back(pspExpanded);
|
vpsPaths.push_back(pspExpanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult terResult;
|
TER terResult;
|
||||||
STAmount saPaid;
|
STAmount saPaid;
|
||||||
STAmount saWanted;
|
STAmount saWanted;
|
||||||
LedgerEntrySet lesBase = mNodes; // Checkpoint with just fees paid.
|
LedgerEntrySet lesBase = mNodes; // Checkpoint with just fees paid.
|
||||||
@@ -3976,7 +4013,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
std::cerr << "WalletAdd>" << std::endl;
|
std::cerr << "WalletAdd>" << std::endl;
|
||||||
|
|
||||||
@@ -4032,7 +4069,7 @@ TransactionEngineResult TransactionEngine::doWalletAdd(const SerializedTransacti
|
|||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doInvoice(const SerializedTransaction& txn)
|
TER TransactionEngine::doInvoice(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
return temUNKNOWN;
|
return temUNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -4045,7 +4082,7 @@ TransactionEngineResult TransactionEngine::doInvoice(const SerializedTransaction
|
|||||||
// <-- saTakerGot: What taker got not including fees. To reduce an offer.
|
// <-- saTakerGot: What taker got not including fees. To reduce an offer.
|
||||||
// <-- terResult: tesSUCCESS or terNO_ACCOUNT
|
// <-- terResult: tesSUCCESS or terNO_ACCOUNT
|
||||||
// XXX: Fees should be paid by the source of the currency.
|
// XXX: Fees should be paid by the source of the currency.
|
||||||
TransactionEngineResult TransactionEngine::takeOffers(
|
TER TransactionEngine::takeOffers(
|
||||||
bool bPassive,
|
bool bPassive,
|
||||||
const uint256& uBookBase,
|
const uint256& uBookBase,
|
||||||
const uint160& uTakerAccountID,
|
const uint160& uTakerAccountID,
|
||||||
@@ -4066,7 +4103,7 @@ TransactionEngineResult TransactionEngine::takeOffers(
|
|||||||
const uint160 uTakerPaysCurrency = saTakerPays.getCurrency();
|
const uint160 uTakerPaysCurrency = saTakerPays.getCurrency();
|
||||||
const uint160 uTakerGetsAccountID = saTakerGets.getIssuer();
|
const uint160 uTakerGetsAccountID = saTakerGets.getIssuer();
|
||||||
const uint160 uTakerGetsCurrency = saTakerGets.getCurrency();
|
const uint160 uTakerGetsCurrency = saTakerGets.getCurrency();
|
||||||
TransactionEngineResult terResult = temUNCERTAIN;
|
TER terResult = temUNCERTAIN;
|
||||||
|
|
||||||
boost::unordered_set<uint256> usOfferUnfundedFound; // Offers found unfunded.
|
boost::unordered_set<uint256> usOfferUnfundedFound; // Offers found unfunded.
|
||||||
boost::unordered_set<uint256> usOfferUnfundedBecame; // Offers that became unfunded.
|
boost::unordered_set<uint256> usOfferUnfundedBecame; // Offers that became unfunded.
|
||||||
@@ -4270,7 +4307,7 @@ TransactionEngineResult TransactionEngine::takeOffers(
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doOfferCreate(const SerializedTransaction& txn)
|
TER TransactionEngine::doOfferCreate(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "doOfferCreate> " << txn.getJson(0);
|
Log(lsWARNING) << "doOfferCreate> " << txn.getJson(0);
|
||||||
const uint32 txFlags = txn.getFlags();
|
const uint32 txFlags = txn.getFlags();
|
||||||
@@ -4294,7 +4331,7 @@ Log(lsWARNING) << "doOfferCreate: saTakerGets=" << saTakerGets.getFullText();
|
|||||||
const uint160 uGetsCurrency = saTakerGets.getCurrency();
|
const uint160 uGetsCurrency = saTakerGets.getCurrency();
|
||||||
const uint64 uRate = STAmount::getRate(saTakerGets, saTakerPays);
|
const uint64 uRate = STAmount::getRate(saTakerGets, saTakerPays);
|
||||||
|
|
||||||
TransactionEngineResult terResult = tesSUCCESS;
|
TER terResult = tesSUCCESS;
|
||||||
uint256 uDirectory; // Delete hints.
|
uint256 uDirectory; // Delete hints.
|
||||||
uint64 uOwnerNode;
|
uint64 uOwnerNode;
|
||||||
uint64 uBookNode;
|
uint64 uBookNode;
|
||||||
@@ -4457,9 +4494,9 @@ Log(lsWARNING) << "doOfferCreate: saTakerGets=" << saTakerGets.getFullText();
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doOfferCancel(const SerializedTransaction& txn)
|
TER TransactionEngine::doOfferCancel(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
TransactionEngineResult terResult;
|
TER terResult;
|
||||||
const uint32 uSequence = txn.getITFieldU32(sfOfferSequence);
|
const uint32 uSequence = txn.getITFieldU32(sfOfferSequence);
|
||||||
const uint256 uOfferIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
const uint256 uOfferIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
||||||
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||||
@@ -4483,17 +4520,17 @@ TransactionEngineResult TransactionEngine::doOfferCancel(const SerializedTransac
|
|||||||
return terResult;
|
return terResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doTake(const SerializedTransaction& txn)
|
TER TransactionEngine::doTake(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
return temUNKNOWN;
|
return temUNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doStore(const SerializedTransaction& txn)
|
TER TransactionEngine::doStore(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
return temUNKNOWN;
|
return temUNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionEngineResult TransactionEngine::doDelete(const SerializedTransaction& txn)
|
TER TransactionEngine::doDelete(const SerializedTransaction& txn)
|
||||||
{
|
{
|
||||||
return temUNKNOWN;
|
return temUNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define __TRANSACTIONENGINE__
|
#define __TRANSACTIONENGINE__
|
||||||
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
// A TransactionEngine applies serialized transactions to a ledger
|
// A TransactionEngine applies serialized transactions to a ledger
|
||||||
// It can also, verify signatures, verify fees, and give rejection reasons
|
// It can also, verify signatures, verify fees, and give rejection reasons
|
||||||
|
|
||||||
enum TransactionEngineResult
|
enum TER // aka TransactionEngineResult
|
||||||
{
|
{
|
||||||
// Note: Range is stable. Exact numbers are currently unstable. Use tokens.
|
// Note: Range is stable. Exact numbers are currently unstable. Use tokens.
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ enum TransactionEngineResult
|
|||||||
tepPATH_PARTIAL,
|
tepPATH_PARTIAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool transResultInfo(TransactionEngineResult terCode, std::string& strToken, std::string& strHuman);
|
bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman);
|
||||||
|
|
||||||
enum TransactionEngineParams
|
enum TransactionEngineParams
|
||||||
{
|
{
|
||||||
@@ -122,6 +123,7 @@ typedef boost::unordered_map<aciSource, unsigned int> curIssuerNode; // Map
|
|||||||
typedef boost::unordered_map<aciSource, unsigned int>::const_iterator curIssuerNodeConstIterator;
|
typedef boost::unordered_map<aciSource, unsigned int>::const_iterator curIssuerNodeConstIterator;
|
||||||
|
|
||||||
extern std::size_t hash_value(const aciSource& asValue);
|
extern std::size_t hash_value(const aciSource& asValue);
|
||||||
|
// extern std::size_t hash_value(const boost::tuple<uint160, uint160, uint160>& bt);
|
||||||
|
|
||||||
// Hold a path state under incremental application.
|
// Hold a path state under incremental application.
|
||||||
class PathState
|
class PathState
|
||||||
@@ -198,12 +200,12 @@ class TransactionEngine
|
|||||||
private:
|
private:
|
||||||
LedgerEntrySet mNodes;
|
LedgerEntrySet mNodes;
|
||||||
|
|
||||||
TransactionEngineResult dirAdd(
|
TER dirAdd(
|
||||||
uint64& uNodeDir, // Node of entry.
|
uint64& uNodeDir, // Node of entry.
|
||||||
const uint256& uRootIndex,
|
const uint256& uRootIndex,
|
||||||
const uint256& uLedgerIndex);
|
const uint256& uLedgerIndex);
|
||||||
|
|
||||||
TransactionEngineResult dirDelete(
|
TER dirDelete(
|
||||||
const bool bKeepRoot,
|
const bool bKeepRoot,
|
||||||
const uint64& uNodeDir, // Node item is mentioned in.
|
const uint64& uNodeDir, // Node item is mentioned in.
|
||||||
const uint256& uRootIndex,
|
const uint256& uRootIndex,
|
||||||
@@ -213,9 +215,9 @@ private:
|
|||||||
bool dirFirst(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
bool dirFirst(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
||||||
bool dirNext(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
bool dirNext(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
||||||
|
|
||||||
TransactionEngineResult setAuthorized(const SerializedTransaction& txn, bool bMustSetGenerator);
|
TER setAuthorized(const SerializedTransaction& txn, bool bMustSetGenerator);
|
||||||
|
|
||||||
TransactionEngineResult takeOffers(
|
TER takeOffers(
|
||||||
bool bPassive,
|
bool bPassive,
|
||||||
const uint256& uBookBase,
|
const uint256& uBookBase,
|
||||||
const uint160& uTakerAccountID,
|
const uint160& uTakerAccountID,
|
||||||
@@ -246,8 +248,8 @@ protected:
|
|||||||
void entryDelete(SLE::pointer sleEntry, bool bUnfunded = false);
|
void entryDelete(SLE::pointer sleEntry, bool bUnfunded = false);
|
||||||
void entryModify(SLE::pointer sleEntry);
|
void entryModify(SLE::pointer sleEntry);
|
||||||
|
|
||||||
TransactionEngineResult offerDelete(const uint256& uOfferIndex);
|
TER offerDelete(const uint256& uOfferIndex);
|
||||||
TransactionEngineResult offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID);
|
TER offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID);
|
||||||
|
|
||||||
uint32 rippleTransferRate(const uint160& uIssuerID);
|
uint32 rippleTransferRate(const uint160& uIssuerID);
|
||||||
STAmount rippleOwed(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
STAmount rippleOwed(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||||
@@ -267,31 +269,31 @@ protected:
|
|||||||
|
|
||||||
PathState::pointer pathCreate(const STPath& spPath);
|
PathState::pointer pathCreate(const STPath& spPath);
|
||||||
void pathNext(const PathState::pointer& pspCur, const int iPaths);
|
void pathNext(const PathState::pointer& pspCur, const int iPaths);
|
||||||
bool calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
TER calcNode(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||||
bool calcNodeOfferRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
TER calcNodeOfferRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||||
bool calcNodeOfferFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
TER calcNodeOfferFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||||
bool calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
TER calcNodeAccountRev(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||||
bool calcNodeAccountFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
TER calcNodeAccountFwd(const unsigned int uIndex, const PathState::pointer& pspCur, const bool bMultiQuality);
|
||||||
void calcNodeRipple(const uint32 uQualityIn, const uint32 uQualityOut,
|
void calcNodeRipple(const uint32 uQualityIn, const uint32 uQualityOut,
|
||||||
const STAmount& saPrvReq, const STAmount& saCurReq,
|
const STAmount& saPrvReq, const STAmount& saCurReq,
|
||||||
STAmount& saPrvAct, STAmount& saCurAct);
|
STAmount& saPrvAct, STAmount& saCurAct);
|
||||||
|
|
||||||
void txnWrite();
|
void txnWrite();
|
||||||
|
|
||||||
TransactionEngineResult doAccountSet(const SerializedTransaction& txn);
|
TER doAccountSet(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doClaim(const SerializedTransaction& txn);
|
TER doClaim(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doCreditSet(const SerializedTransaction& txn);
|
TER doCreditSet(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doDelete(const SerializedTransaction& txn);
|
TER doDelete(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doInvoice(const SerializedTransaction& txn);
|
TER doInvoice(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doOfferCreate(const SerializedTransaction& txn);
|
TER doOfferCreate(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doOfferCancel(const SerializedTransaction& txn);
|
TER doOfferCancel(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doNicknameSet(const SerializedTransaction& txn);
|
TER doNicknameSet(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doPasswordFund(const SerializedTransaction& txn);
|
TER doPasswordFund(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doPasswordSet(const SerializedTransaction& txn);
|
TER doPasswordSet(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doPayment(const SerializedTransaction& txn);
|
TER doPayment(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doStore(const SerializedTransaction& txn);
|
TER doStore(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doTake(const SerializedTransaction& txn);
|
TER doTake(const SerializedTransaction& txn);
|
||||||
TransactionEngineResult doWalletAdd(const SerializedTransaction& txn);
|
TER doWalletAdd(const SerializedTransaction& txn);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransactionEngine() { ; }
|
TransactionEngine() { ; }
|
||||||
@@ -300,7 +302,7 @@ public:
|
|||||||
Ledger::pointer getLedger() { return mLedger; }
|
Ledger::pointer getLedger() { return mLedger; }
|
||||||
void setLedger(const Ledger::pointer& ledger) { assert(ledger); mLedger = ledger; }
|
void setLedger(const Ledger::pointer& ledger) { assert(ledger); mLedger = ledger; }
|
||||||
|
|
||||||
TransactionEngineResult applyTransaction(const SerializedTransaction&, TransactionEngineParams);
|
TER applyTransaction(const SerializedTransaction&, TransactionEngineParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline TransactionEngineParams operator|(const TransactionEngineParams& l1, const TransactionEngineParams& l2)
|
inline TransactionEngineParams operator|(const TransactionEngineParams& l1, const TransactionEngineParams& l2)
|
||||||
|
|||||||
Reference in New Issue
Block a user