Fix unfunded offer not removed (RIPD-1298):

If the mantissas of two non-native amounts differ by less than 10, then
subtracting them leaves a result of zero. This can cause situations
where `a>b`, yet `a-b == 0`.

One consequence of this is unfunded offers were incorrectly left in
order books. The code would check if the offer would be
consumed (`amount in offer > amount needed`), assume it wouldn't be,
yet when `amount needed` was subtracted from `amount in offer` the
result was zero and the offer was unfunded. This unfunded offer
incorrectly remained on the order book.

This patch fixes this bug.
This commit is contained in:
seelabs
2016-09-16 11:19:51 -04:00
committed by Vinnie Falco
parent 3b639afac2
commit bb0b97f46b
4 changed files with 109 additions and 6 deletions

View File

@@ -58,6 +58,20 @@ bool amendmentRIPD1274 (NetClock::time_point const closeTime)
return closeTime > amendmentRIPD1274SoTime();
}
NetClock::time_point const& amendmentRIPD1298SoTime ()
{
using namespace std::chrono_literals;
// TBD Move this date up when we know the release date
// Thu Jan 5, 2017 10:00:00am PDT
static NetClock::time_point const soTime{536954400s};
return soTime;
}
bool amendmentRIPD1298 (NetClock::time_point const closeTime)
{
return closeTime > amendmentRIPD1298SoTime();
}
// VFALCO NOTE A copy of the other one for now
/** Maximum number of entries in a directory page
A change would be protocol-breaking.