mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -38,6 +38,7 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
|
|
||||||
cLog(lsINFO) << "takeOffers: against book: " << uBookBase.ToString();
|
cLog(lsINFO) << "takeOffers: against book: " << uBookBase.ToString();
|
||||||
|
|
||||||
|
LedgerEntrySet& lesActive = mEngine->getNodes();
|
||||||
uint256 uTipIndex = uBookBase;
|
uint256 uTipIndex = uBookBase;
|
||||||
const uint256 uBookEnd = Ledger::getQualityNext(uBookBase);
|
const uint256 uBookEnd = Ledger::getQualityNext(uBookBase);
|
||||||
const uint64 uTakeQuality = STAmount::getRate(saTakerGets, saTakerPays);
|
const uint64 uTakeQuality = STAmount::getRate(saTakerGets, saTakerPays);
|
||||||
@@ -57,7 +58,7 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
{
|
{
|
||||||
SLE::pointer sleOfferDir;
|
SLE::pointer sleOfferDir;
|
||||||
uint64 uTipQuality = 0;
|
uint64 uTipQuality = 0;
|
||||||
STAmount saTakerFunds = mEngine->getNodes().accountFunds(uTakerAccountID, saTakerPays);
|
STAmount saTakerFunds = lesActive.accountFunds(uTakerAccountID, saTakerPays);
|
||||||
STAmount saSubTakerPays = saTakerPays-saTakerPaid; // How much more to spend.
|
STAmount saSubTakerPays = saTakerPays-saTakerPaid; // How much more to spend.
|
||||||
STAmount saSubTakerGets = saTakerGets-saTakerGot; // How much more is wanted.
|
STAmount saSubTakerGets = saTakerGets-saTakerGot; // How much more is wanted.
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
unsigned int uBookEntry;
|
unsigned int uBookEntry;
|
||||||
uint256 uOfferIndex;
|
uint256 uOfferIndex;
|
||||||
|
|
||||||
mEngine->getNodes().dirFirst(uTipIndex, sleBookNode, uBookEntry, uOfferIndex);
|
lesActive.dirFirst(uTipIndex, sleBookNode, uBookEntry, uOfferIndex);
|
||||||
|
|
||||||
SLE::pointer sleOffer = mEngine->entryCache(ltOFFER, uOfferIndex);
|
SLE::pointer sleOffer = mEngine->entryCache(ltOFFER, uOfferIndex);
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
|
|
||||||
cLog(lsINFO) << "takeOffers: saOfferPays=" << saOfferPays.getFullText();
|
cLog(lsINFO) << "takeOffers: saOfferPays=" << saOfferPays.getFullText();
|
||||||
|
|
||||||
STAmount saOfferFunds = mEngine->getNodes().accountFunds(uOfferOwnerID, saOfferPays);
|
STAmount saOfferFunds = lesActive.accountFunds(uOfferOwnerID, saOfferPays);
|
||||||
SLE::pointer sleOfferAccount; // Owner of offer.
|
SLE::pointer sleOfferAccount; // Owner of offer.
|
||||||
|
|
||||||
if (!saOfferFunds.isPositive()) // Includes zero.
|
if (!saOfferFunds.isPositive()) // Includes zero.
|
||||||
@@ -209,8 +210,8 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
cLog(lsINFO) << "takeOffers: applyOffer: saTakerGets: " << saTakerGets.getFullText();
|
cLog(lsINFO) << "takeOffers: applyOffer: saTakerGets: " << saTakerGets.getFullText();
|
||||||
|
|
||||||
bool bOfferDelete = STAmount::applyOffer(
|
bool bOfferDelete = STAmount::applyOffer(
|
||||||
mEngine->getNodes().rippleTransferRate(uTakerAccountID, uOfferOwnerID, uTakerPaysAccountID),
|
lesActive.rippleTransferRate(uTakerAccountID, uOfferOwnerID, uTakerPaysAccountID),
|
||||||
mEngine->getNodes().rippleTransferRate(uOfferOwnerID, uTakerAccountID, uTakerGetsAccountID),
|
lesActive.rippleTransferRate(uOfferOwnerID, uTakerAccountID, uTakerGetsAccountID),
|
||||||
saOfferRate,
|
saOfferRate,
|
||||||
saOfferFunds,
|
saOfferFunds,
|
||||||
saTakerFunds,
|
saTakerFunds,
|
||||||
@@ -273,10 +274,10 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
{
|
{
|
||||||
// Distribute funds. The sends charge appropriate fees which are implied by offer.
|
// Distribute funds. The sends charge appropriate fees which are implied by offer.
|
||||||
|
|
||||||
terResult = mEngine->getNodes().accountSend(uOfferOwnerID, uTakerAccountID, saSubTakerGot); // Offer owner pays taker.
|
terResult = lesActive.accountSend(uOfferOwnerID, uTakerAccountID, saSubTakerGot); // Offer owner pays taker.
|
||||||
|
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
terResult = mEngine->getNodes().accountSend(uTakerAccountID, uOfferOwnerID, saSubTakerPaid); // Taker pays offer owner.
|
terResult = lesActive.accountSend(uTakerAccountID, uOfferOwnerID, saSubTakerPaid); // Taker pays offer owner.
|
||||||
|
|
||||||
// Reduce amount considered paid by taker's rate (not actual cost).
|
// Reduce amount considered paid by taker's rate (not actual cost).
|
||||||
STAmount saTakerCould = saTakerPays - saTakerPaid; // Taker could pay.
|
STAmount saTakerCould = saTakerPays - saTakerPaid; // Taker could pay.
|
||||||
@@ -310,7 +311,7 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
{
|
{
|
||||||
cLog(lsINFO) << "takeOffers: became unfunded: " << uOfferIndex.ToString();
|
cLog(lsINFO) << "takeOffers: became unfunded: " << uOfferIndex.ToString();
|
||||||
|
|
||||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
terResult = lesActive.offerDelete(uOfferIndex);
|
||||||
if (tesSUCCESS != terResult)
|
if (tesSUCCESS != terResult)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -356,6 +357,9 @@ TER OfferCreateTransactor::doApply()
|
|||||||
|
|
||||||
LedgerEntrySet& lesActive = mEngine->getNodes();
|
LedgerEntrySet& lesActive = mEngine->getNodes();
|
||||||
LedgerEntrySet lesCheckpoint = lesActive; // Checkpoint with just fees paid.
|
LedgerEntrySet lesCheckpoint = lesActive; // Checkpoint with just fees paid.
|
||||||
|
lesActive.bumpSeq(); // Begin ledger variance.
|
||||||
|
|
||||||
|
SLE::pointer slePayment = mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mTxnAccountID));
|
||||||
|
|
||||||
if (uTxFlags & tfOfferCreateMask)
|
if (uTxFlags & tfOfferCreateMask)
|
||||||
{
|
{
|
||||||
@@ -405,7 +409,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
|
|
||||||
terResult = temBAD_ISSUER;
|
terResult = temBAD_ISSUER;
|
||||||
}
|
}
|
||||||
else if (!mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets).isPositive())
|
else if (!lesActive.accountFunds(mTxnAccountID, saTakerGets).isPositive())
|
||||||
{
|
{
|
||||||
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
|
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
|
||||||
|
|
||||||
@@ -446,7 +450,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
bPassive,
|
bPassive,
|
||||||
uTakeBookBase,
|
uTakeBookBase,
|
||||||
mTxnAccountID,
|
mTxnAccountID,
|
||||||
mTxnAccount,
|
slePayment,
|
||||||
saTakerGets, // Reverse as we are the taker for taking.
|
saTakerGets, // Reverse as we are the taker for taking.
|
||||||
saTakerPays,
|
saTakerPays,
|
||||||
saPaid, // How much would have spent at full price.
|
saPaid, // How much would have spent at full price.
|
||||||
@@ -470,7 +474,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
cLog(lsWARNING) << "OfferCreate: takeOffers: saTakerPays=" << saTakerPays.getFullText();
|
cLog(lsWARNING) << "OfferCreate: takeOffers: saTakerPays=" << saTakerPays.getFullText();
|
||||||
cLog(lsWARNING) << "OfferCreate: takeOffers: saTakerGets=" << saTakerGets.getFullText();
|
cLog(lsWARNING) << "OfferCreate: takeOffers: saTakerGets=" << saTakerGets.getFullText();
|
||||||
cLog(lsWARNING) << "OfferCreate: takeOffers: mTxnAccountID=" << RippleAddress::createHumanAccountID(mTxnAccountID);
|
cLog(lsWARNING) << "OfferCreate: takeOffers: mTxnAccountID=" << RippleAddress::createHumanAccountID(mTxnAccountID);
|
||||||
cLog(lsWARNING) << "OfferCreate: takeOffers: FUNDS=" << mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets).getFullText();
|
cLog(lsWARNING) << "OfferCreate: takeOffers: FUNDS=" << lesActive.accountFunds(mTxnAccountID, saTakerGets).getFullText();
|
||||||
|
|
||||||
// cLog(lsWARNING) << "OfferCreate: takeOffers: uPaysIssuerID=" << RippleAddress::createHumanAccountID(uPaysIssuerID);
|
// cLog(lsWARNING) << "OfferCreate: takeOffers: uPaysIssuerID=" << RippleAddress::createHumanAccountID(uPaysIssuerID);
|
||||||
// cLog(lsWARNING) << "OfferCreate: takeOffers: uGetsIssuerID=" << RippleAddress::createHumanAccountID(uGetsIssuerID);
|
// cLog(lsWARNING) << "OfferCreate: takeOffers: uGetsIssuerID=" << RippleAddress::createHumanAccountID(uGetsIssuerID);
|
||||||
@@ -493,8 +497,8 @@ TER OfferCreateTransactor::doApply()
|
|||||||
else if (
|
else if (
|
||||||
!saTakerPays // Wants nothing more.
|
!saTakerPays // Wants nothing more.
|
||||||
|| !saTakerGets // Offering nothing more.
|
|| !saTakerGets // Offering nothing more.
|
||||||
|| bImmediateOrCancel // Do not persist.
|
|| bImmediateOrCancel // Do not persist.
|
||||||
|| !mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets).isPositive() // Not funded.
|
|| !lesActive.accountFunds(mTxnAccountID, saTakerGets).isPositive() // Not funded.
|
||||||
|| bUnfunded) // Consider unfunded.
|
|| bUnfunded) // Consider unfunded.
|
||||||
{
|
{
|
||||||
// Complete as is.
|
// Complete as is.
|
||||||
@@ -529,14 +533,14 @@ TER OfferCreateTransactor::doApply()
|
|||||||
% saTakerGets.getFullText());
|
% saTakerGets.getFullText());
|
||||||
|
|
||||||
// Add offer to owner's directory.
|
// Add offer to owner's directory.
|
||||||
terResult = mEngine->getNodes().dirAdd(uOwnerNode, Ledger::getOwnerDirIndex(mTxnAccountID), uLedgerIndex,
|
terResult = lesActive.dirAdd(uOwnerNode, Ledger::getOwnerDirIndex(mTxnAccountID), uLedgerIndex,
|
||||||
boost::bind(&Ledger::qualityDirDescriber, _1, saTakerPays.getCurrency(), uPaysIssuerID,
|
boost::bind(&Ledger::qualityDirDescriber, _1, saTakerPays.getCurrency(), uPaysIssuerID,
|
||||||
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
||||||
|
|
||||||
|
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
{
|
{
|
||||||
mEngine->getNodes().ownerCountAdjust(mTxnAccountID, 1, mTxnAccount); // Update owner count.
|
lesActive.ownerCountAdjust(mTxnAccountID, 1, slePayment); // Update owner count.
|
||||||
|
|
||||||
uint256 uBookBase = Ledger::getBookBase(uPaysCurrency, uPaysIssuerID, uGetsCurrency, uGetsIssuerID);
|
uint256 uBookBase = Ledger::getBookBase(uPaysCurrency, uPaysIssuerID, uGetsCurrency, uGetsIssuerID);
|
||||||
|
|
||||||
@@ -550,7 +554,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
uDirectory = Ledger::getQualityIndex(uBookBase, uRate); // Use original rate.
|
uDirectory = Ledger::getQualityIndex(uBookBase, uRate); // Use original rate.
|
||||||
|
|
||||||
// Add offer to order book.
|
// Add offer to order book.
|
||||||
terResult = mEngine->getNodes().dirAdd(uBookNode, uDirectory, uLedgerIndex,
|
terResult = lesActive.dirAdd(uBookNode, uDirectory, uLedgerIndex,
|
||||||
boost::bind(&Ledger::qualityDirDescriber, _1, saTakerPays.getCurrency(), uPaysIssuerID,
|
boost::bind(&Ledger::qualityDirDescriber, _1, saTakerPays.getCurrency(), uPaysIssuerID,
|
||||||
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
||||||
}
|
}
|
||||||
@@ -595,7 +599,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
|
|
||||||
cLog(lsINFO) << "takeOffers: found unfunded: " << uOfferIndex.ToString();
|
cLog(lsINFO) << "takeOffers: found unfunded: " << uOfferIndex.ToString();
|
||||||
|
|
||||||
terResult = mEngine->getNodes().offerDelete(uOfferIndex);
|
terResult = lesActive.offerDelete(uOfferIndex);
|
||||||
if (tesSUCCESS != terResult)
|
if (tesSUCCESS != terResult)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -957,7 +957,7 @@ TER RippleCalc::calcNodeAdvance(
|
|||||||
// An internal error previously left a bad offer.
|
// An internal error previously left a bad offer.
|
||||||
cLog(lsWARNING) << boost::str(boost::format("calcNodeAdvance: INTERNAL ERROR: OFFER NON-POSITIVE: saTakerPays=%s saTakerGets=%s")
|
cLog(lsWARNING) << boost::str(boost::format("calcNodeAdvance: INTERNAL ERROR: OFFER NON-POSITIVE: saTakerPays=%s saTakerGets=%s")
|
||||||
% saTakerPays % saTakerGets);
|
% saTakerPays % saTakerGets);
|
||||||
assert(false);
|
//assert(false);
|
||||||
// Don't process at all, things are in an unexpected state for this transactions.
|
// Don't process at all, things are in an unexpected state for this transactions.
|
||||||
terResult = tefEXCEPTION;
|
terResult = tefEXCEPTION;
|
||||||
}
|
}
|
||||||
@@ -2471,7 +2471,7 @@ void RippleCalc::pathNext(PathState::ref psrCur, const bool bMultiQuality, const
|
|||||||
assert(psrCur->vpnNodes.size() >= 2);
|
assert(psrCur->vpnNodes.size() >= 2);
|
||||||
|
|
||||||
lesCurrent = lesCheckpoint; // Restore from checkpoint.
|
lesCurrent = lesCheckpoint; // Restore from checkpoint.
|
||||||
lesCurrent.bumpSeq(); // Begin ledger varance.
|
lesCurrent.bumpSeq(); // Begin ledger variance.
|
||||||
|
|
||||||
psrCur->terStatus = calcNodeRev(uLast, *psrCur, bMultiQuality);
|
psrCur->terStatus = calcNodeRev(uLast, *psrCur, bMultiQuality);
|
||||||
|
|
||||||
@@ -2481,7 +2481,7 @@ void RippleCalc::pathNext(PathState::ref psrCur, const bool bMultiQuality, const
|
|||||||
{
|
{
|
||||||
// Do forward.
|
// Do forward.
|
||||||
lesCurrent = lesCheckpoint; // Restore from checkpoint.
|
lesCurrent = lesCheckpoint; // Restore from checkpoint.
|
||||||
lesCurrent.bumpSeq(); // Begin ledger varance.
|
lesCurrent.bumpSeq(); // Begin ledger variance.
|
||||||
|
|
||||||
psrCur->terStatus = calcNodeFwd(0, *psrCur, bMultiQuality);
|
psrCur->terStatus = calcNodeFwd(0, *psrCur, bMultiQuality);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user