mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -339,31 +339,32 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
TER OfferCreateTransactor::doApply()
|
TER OfferCreateTransactor::doApply()
|
||||||
{
|
{
|
||||||
cLog(lsWARNING) << "OfferCreate> " << mTxn.getJson(0);
|
cLog(lsWARNING) << "OfferCreate> " << mTxn.getJson(0);
|
||||||
const uint32 uTxFlags = mTxn.getFlags();
|
const uint32 uTxFlags = mTxn.getFlags();
|
||||||
const bool bPassive = isSetBit(uTxFlags, tfPassive);
|
const bool bPassive = isSetBit(uTxFlags, tfPassive);
|
||||||
const bool bMarket = isSetBit(uTxFlags, tfMarket);
|
const bool bImmediateOrCancel = isSetBit(uTxFlags, tfImmediateOrCancel);
|
||||||
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
|
const bool bFillOrKill = isSetBit(uTxFlags, tfFillOrKill);
|
||||||
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
|
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
|
||||||
|
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
|
||||||
|
|
||||||
cLog(lsINFO) << boost::str(boost::format("OfferCreate: saTakerPays=%s saTakerGets=%s")
|
cLog(lsINFO) << boost::str(boost::format("OfferCreate: saTakerPays=%s saTakerGets=%s")
|
||||||
% saTakerPays.getFullText()
|
% saTakerPays.getFullText()
|
||||||
% saTakerGets.getFullText());
|
% saTakerGets.getFullText());
|
||||||
|
|
||||||
const uint160 uPaysIssuerID = saTakerPays.getIssuer();
|
const uint160 uPaysIssuerID = saTakerPays.getIssuer();
|
||||||
const uint160 uGetsIssuerID = saTakerGets.getIssuer();
|
const uint160 uGetsIssuerID = saTakerGets.getIssuer();
|
||||||
const uint32 uExpiration = mTxn.getFieldU32(sfExpiration);
|
const uint32 uExpiration = mTxn.getFieldU32(sfExpiration);
|
||||||
const bool bHaveExpiration = mTxn.isFieldPresent(sfExpiration);
|
const bool bHaveExpiration = mTxn.isFieldPresent(sfExpiration);
|
||||||
const uint32 uSequence = mTxn.getSequence();
|
const uint32 uSequence = mTxn.getSequence();
|
||||||
|
|
||||||
const uint256 uLedgerIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
const uint256 uLedgerIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
||||||
|
|
||||||
cLog(lsINFO) << "OfferCreate: Creating offer node: " << uLedgerIndex.ToString() << " uSequence=" << uSequence;
|
cLog(lsINFO) << "OfferCreate: Creating offer node: " << uLedgerIndex.ToString() << " uSequence=" << uSequence;
|
||||||
|
|
||||||
const uint160 uPaysCurrency = saTakerPays.getCurrency();
|
const uint160 uPaysCurrency = saTakerPays.getCurrency();
|
||||||
const uint160 uGetsCurrency = saTakerGets.getCurrency();
|
const uint160 uGetsCurrency = saTakerGets.getCurrency();
|
||||||
const uint64 uRate = STAmount::getRate(saTakerGets, saTakerPays);
|
const uint64 uRate = STAmount::getRate(saTakerGets, saTakerPays);
|
||||||
|
|
||||||
TER terResult = tesSUCCESS;
|
TER terResult = tesSUCCESS;
|
||||||
uint256 uDirectory; // Delete hints.
|
uint256 uDirectory; // Delete hints.
|
||||||
uint64 uOwnerNode;
|
uint64 uOwnerNode;
|
||||||
uint64 uBookNode;
|
uint64 uBookNode;
|
||||||
@@ -374,6 +375,12 @@ TER OfferCreateTransactor::doApply()
|
|||||||
|
|
||||||
return temINVALID_FLAG;
|
return temINVALID_FLAG;
|
||||||
}
|
}
|
||||||
|
else if (bImmediateOrCancel && bFillOrKill)
|
||||||
|
{
|
||||||
|
cLog(lsINFO) << "OfferCreate: Malformed transaction: both IoC and FoK set.";
|
||||||
|
|
||||||
|
return temINVALID_FLAG;
|
||||||
|
}
|
||||||
else if (bHaveExpiration && !uExpiration)
|
else if (bHaveExpiration && !uExpiration)
|
||||||
{
|
{
|
||||||
cLog(lsWARNING) << "OfferCreate: Malformed offer: bad expiration";
|
cLog(lsWARNING) << "OfferCreate: Malformed offer: bad expiration";
|
||||||
@@ -490,10 +497,15 @@ TER OfferCreateTransactor::doApply()
|
|||||||
// If ledger is not final, can vote no.
|
// If ledger is not final, can vote no.
|
||||||
terResult = bOpenLedger ? telFAILED_PROCESSING : tecFAILED_PROCESSING;
|
terResult = bOpenLedger ? telFAILED_PROCESSING : tecFAILED_PROCESSING;
|
||||||
}
|
}
|
||||||
|
else if (bFillOrKill && (saTakerPays || saTakerGets))
|
||||||
|
{
|
||||||
|
// Fill or kill and have leftovers.
|
||||||
|
terResult = tecKILL;
|
||||||
|
}
|
||||||
else if (
|
else if (
|
||||||
!saTakerPays // Wants nothing more.
|
!saTakerPays // Wants nothing more.
|
||||||
|| !saTakerGets // Offering nothing more.
|
|| !saTakerGets // Offering nothing more.
|
||||||
|| bMarket // Do not persist.
|
|| bImmediateOrCancel // Do not persist.
|
||||||
|| !mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets).isPositive() // Not funded.
|
|| !mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets).isPositive() // Not funded.
|
||||||
|| bUnfunded) // Consider unfunded.
|
|| bUnfunded) // Consider unfunded.
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ enum TER // aka TransactionEngineResult
|
|||||||
tecUNFUNDED_OFFER = 103,
|
tecUNFUNDED_OFFER = 103,
|
||||||
tecUNFUNDED_PAYMENT = 104,
|
tecUNFUNDED_PAYMENT = 104,
|
||||||
tecFAILED_PROCESSING = 105,
|
tecFAILED_PROCESSING = 105,
|
||||||
|
tecKILL = 106, // tesSUCCESS is not retryable.
|
||||||
tecDIR_FULL = 121,
|
tecDIR_FULL = 121,
|
||||||
tecINSUF_RESERVE_LINE = 122,
|
tecINSUF_RESERVE_LINE = 122,
|
||||||
tecINSUF_RESERVE_OFFER = 123,
|
tecINSUF_RESERVE_OFFER = 123,
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ const uint32 tfAccountSetMask = ~(tfRequireDestTag|tfOptionalDestTag|tfRequireA
|
|||||||
|
|
||||||
// OfferCreate flags:
|
// OfferCreate flags:
|
||||||
const uint32 tfPassive = 0x00010000;
|
const uint32 tfPassive = 0x00010000;
|
||||||
const uint32 tfMarket = 0x00020000;
|
const uint32 tfImmediateOrCancel = 0x00020000;
|
||||||
const uint32 tfOfferCreateMask = ~(tfPassive|tfMarket);
|
const uint32 tfFillOrKill = 0x00040000;
|
||||||
|
const uint32 tfOfferCreateMask = ~(tfPassive|tfImmediateOrCancel|tfFillOrKill);
|
||||||
|
|
||||||
// Payment flags:
|
// Payment flags:
|
||||||
const uint32 tfNoRippleDirect = 0x00010000;
|
const uint32 tfNoRippleDirect = 0x00010000;
|
||||||
|
|||||||
Reference in New Issue
Block a user