Reduce STAmount public interface (RIPD-867):

* Implement subtraction as addition to the additive inverse
* Do not allow comparison with, addition to or subtraction from integers
* Remove unused functions
* Convert member functions to free functions
* Isolate unit-test specific code into the unit test
This commit is contained in:
Nik Bougalis
2015-05-17 10:29:47 -07:00
parent 67b18e4bea
commit 6f5d8bba2d
19 changed files with 351 additions and 541 deletions

View File

@@ -2888,9 +2888,8 @@ void NetworkOPsImp::getBookPage (
uOfferRate = uTransferRate;
saOwnerFundsLimit = divide (
saOwnerFunds,
STAmount (noIssue(), uOfferRate, -9),
amountFromRate (uOfferRate),
saOwnerFunds.issue ());
// TODO(tom): why -9?
}
else
{
@@ -2922,7 +2921,7 @@ void NetworkOPsImp::getBookPage (
saOwnerFunds,
multiply (
saTakerGetsFunded,
STAmount (noIssue(), uOfferRate, -9),
amountFromRate (uOfferRate),
saTakerGetsFunded.issue ()));
umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
@@ -3053,9 +3052,8 @@ void NetworkOPsImp::getBookPage (
{
// Need to charge a transfer fee to offer owner.
uOfferRate = uTransferRate;
// TODO(tom): where does -9 come from?!
STAmount amount (noIssue(), uOfferRate, -9);
saOwnerFundsLimit = divide (saOwnerFunds, amount);
saOwnerFundsLimit = divide (saOwnerFunds,
amountFromRate (uOfferRate));
}
else
{
@@ -3083,12 +3081,10 @@ void NetworkOPsImp::getBookPage (
}
STAmount saOwnerPays = (uOfferRate == QUALITY_ONE)
? saTakerGetsFunded
: std::min (saOwnerFunds,
multiply (
saTakerGetsFunded, STAmount (
noIssue(), uOfferRate,
-9)));
? saTakerGetsFunded
: std::min (
saOwnerFunds,
multiply (saTakerGetsFunded, amountFromRate (uOfferRate)));
umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;