Skip to content

Commit 0644a05

Browse files
committed
Sorting order for marketplace offers
1 parent 7a27358 commit 0644a05

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

state/s_mktswap.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,17 @@ QVector<MktSwapOffer> SwapMarketplace::getMarketOffers(double minFeeLevel, int s
468468
}
469469
}
470470

471-
if (selling == 1)
472-
std::sort( result.begin(), result.end(), []( const MktSwapOffer & o1, const MktSwapOffer & o2 ) {
473-
return o1.calcRate() > o2.calcRate();
474-
} );
475-
else
476-
std::sort( result.begin(), result.end(), []( const MktSwapOffer & o1, const MktSwapOffer & o2 ) {
471+
// Sorting should be the same for all typy of deals
472+
std::sort( result.begin(), result.end(), []( const MktSwapOffer & o1, const MktSwapOffer & o2 ) {
473+
if (o1.sell != o2.sell)
474+
return o1.sell;
475+
476+
Q_ASSERT(o1.sell == o2.sell);
477+
if (o1.sell)
477478
return o1.calcRate() < o2.calcRate();
478-
} );
479+
else
480+
return o1.calcRate() > o2.calcRate();
481+
} );
479482

480483
return result;
481484
}

0 commit comments

Comments
 (0)