You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am here talking about the price object and it's operator <
I assume that the price object compares a ratio, and not the actual numbers. But the code indicates that it first compares the instance IDs, and then compares the product of base and quote of the two objects.
Anomaly 1: I would assume that given asset object with the IDs of 1 and 2, the price does not play into it at all. 1 is less than 2, regardless of the price. So to do a legit comparison, you must assure the base and quote of the two are the same. Otherwise you will get an ID comparison and not price.
Anomaly 2: The prices are compared by multiplication instead of ratios. Hence:
const auto& a = create_bitasset("ASSETA");
const auto& b = create_bitasset("ASSETB");
// now compare IDs
price p1( asset( 100, a.id), asset( 100, b.id) );
price p2( asset( 100, b.id), asset( 100, a.id) );
BOOST_CHECK( p1 < p2 ); // checks ids, and sees P1's base ID is less than P2's
BOOST_CHECK( p2 > p1 ); // the opposite should also be true
// now compare prices
price p3( asset( 1, a.id), asset( 2, b.id) );
price p4( asset( 100, a.id), asset( 200, b.id) );
// those prices are equal, but it doesn't come out that way
BOOST_CHECK( p1 < p2 );
BOOST_CHECK( p2 > p1 );
passes. Even though prices P3 and P4 are in essence equal. Is this a bug, or simply must be kept in mind as an implementation detail?
These lines of code appeared twice in your test case.
BOOST_CHECK( p1 < p2 );
BOOST_CHECK( p2 > p1 );
Prices are compared by asset IDs first because we need to index them with by_price tag in databases, to get orders on the same side of a market one by one. So the direction (base vs quote) matters.
I am not sure if this is a "feature" or a bug...
I am here talking about the
price
object and it'soperator <
I assume that the price object compares a ratio, and not the actual numbers. But the code indicates that it first compares the instance IDs, and then compares the product of base and quote of the two objects.
Anomaly 1: I would assume that given asset object with the IDs of 1 and 2, the price does not play into it at all. 1 is less than 2, regardless of the price. So to do a legit comparison, you must assure the base and quote of the two are the same. Otherwise you will get an ID comparison and not price.
Anomaly 2: The prices are compared by multiplication instead of ratios. Hence:
passes. Even though prices P3 and P4 are in essence equal. Is this a bug, or simply must be kept in mind as an implementation detail?
Perhaps a related tangent: #1094
The text was updated successfully, but these errors were encountered: