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 bool bPassive = isSetBit(uTxFlags, tfPassive);
const bool bImmediateOrCancel = isSetBit(uTxFlags, tfImmediateOrCancel);
const bool bFillOrKill = isSetBit(uTxFlags, tfFillOrKill);
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
@@ -374,6 +375,12 @@ TER OfferCreateTransactor::doApply()
return temINVALID_FLAG;
}
else if (bImmediateOrCancel && bFillOrKill)
{
cLog(lsINFO) << "OfferCreate: Malformed transaction: both IoC and FoK set.";
return temINVALID_FLAG;
}
else if (bHaveExpiration && !uExpiration)
{
cLog(lsWARNING) << "OfferCreate: Malformed offer: bad expiration";
@@ -490,6 +497,11 @@ TER OfferCreateTransactor::doApply()
// If ledger is not final, can vote no.
terResult = bOpenLedger ? telFAILED_PROCESSING : tecFAILED_PROCESSING;
}
else if (bFillOrKill && (saTakerPays || saTakerGets))
{
// Fill or kill and have leftovers.
terResult = tecKILL;
}
else if (
!saTakerPays // Wants nothing more.
|| !saTakerGets // Offering nothing more.