Add fill or kill support.

This commit is contained in:
Arthur Britto
2013-03-06 01:22:35 -08:00
parent 64994268d3
commit f47bf56ac8
3 changed files with 15 additions and 1 deletions

View File

@@ -342,6 +342,7 @@ TER OfferCreateTransactor::doApply()
const uint32 uTxFlags = mTxn.getFlags(); const uint32 uTxFlags = mTxn.getFlags();
const bool bPassive = isSetBit(uTxFlags, tfPassive); const bool bPassive = isSetBit(uTxFlags, tfPassive);
const bool bImmediateOrCancel = isSetBit(uTxFlags, tfImmediateOrCancel); const bool bImmediateOrCancel = isSetBit(uTxFlags, tfImmediateOrCancel);
const bool bFillOrKill = isSetBit(uTxFlags, tfFillOrKill);
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays); STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets); STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
@@ -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,6 +497,11 @@ 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.

View File

@@ -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,

View File

@@ -69,7 +69,8 @@ const uint32 tfAccountSetMask = ~(tfRequireDestTag|tfOptionalDestTag|tfRequireA
// OfferCreate flags: // OfferCreate flags:
const uint32 tfPassive = 0x00010000; const uint32 tfPassive = 0x00010000;
const uint32 tfImmediateOrCancel = 0x00020000; const uint32 tfImmediateOrCancel = 0x00020000;
const uint32 tfOfferCreateMask = ~(tfPassive|tfImmediateOrCancel); const uint32 tfFillOrKill = 0x00040000;
const uint32 tfOfferCreateMask = ~(tfPassive|tfImmediateOrCancel|tfFillOrKill);
// Payment flags: // Payment flags:
const uint32 tfNoRippleDirect = 0x00010000; const uint32 tfNoRippleDirect = 0x00010000;