Skip to content

Commit

Permalink
Fix amount issue after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman committed Jun 3, 2021
1 parent 06afd83 commit 5bda54d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
26 changes: 13 additions & 13 deletions src/ripple/app/tx/impl/OfferStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ TOfferStreamBase<TIn, TOut>::shouldRmSmallIncreasedQOffer() const
{
static_assert(
std::is_same_v<TTakerPays, IOUAmount> ||
std::is_same_v<TTakerPays, XRPAmount>,
std::is_same_v<TTakerPays, BRTAmount>,
"STAmount is not supported");

static_assert(
std::is_same_v<TTakerGets, IOUAmount> ||
std::is_same_v<TTakerGets, XRPAmount>,
std::is_same_v<TTakerGets, BRTAmount>,
"STAmount is not supported");

static_assert(
!std::is_same_v<TTakerPays, XRPAmount> ||
!std::is_same_v<TTakerGets, XRPAmount>,
!std::is_same_v<TTakerPays, BRTAmount> ||
!std::is_same_v<TTakerGets, BRTAmount>,
"Cannot have XRP/XRP offers");

if (!view_.rules().enabled(fixRmSmallIncreasedQOffers))
Expand All @@ -159,8 +159,8 @@ TOfferStreamBase<TIn, TOut>::shouldRmSmallIncreasedQOffer() const
// Consider removing the offer if:
// o `TakerPays` is XRP (because of XRP drops granularity) or
// o `TakerPays` and `TakerGets` are both IOU and `TakerPays`<`TakerGets`
constexpr bool const inIsXRP = std::is_same_v<TTakerPays, XRPAmount>;
constexpr bool const outIsXRP = std::is_same_v<TTakerGets, XRPAmount>;
constexpr bool const inIsXRP = std::is_same_v<TTakerPays, BRTAmount>;
constexpr bool const outIsXRP = std::is_same_v<TTakerGets, BRTAmount>;

if constexpr (outIsXRP)
{
Expand Down Expand Up @@ -303,24 +303,24 @@ TOfferStreamBase<TIn, TOut>::step()
// `shouldRmSmallIncreasedQOffer` template will be instantiated
// even if it is never used. This can cause compiler errors in
// some cases, hence the `if constexpr` guard.
// Note that TIn can be XRPAmount or STAmount, and TOut can be
// Note that TIn can be BRTAmount or STAmount, and TOut can be
// IOUAmount or STAmount.
if constexpr (!(std::is_same_v<TIn, IOUAmount> ||
std::is_same_v<TOut, XRPAmount>))
return shouldRmSmallIncreasedQOffer<XRPAmount, IOUAmount>();
std::is_same_v<TOut, BRTAmount>))
return shouldRmSmallIncreasedQOffer<BRTAmount, IOUAmount>();
}
if (!inIsXRP && outIsXRP)
{
// See comment above for `if constexpr` rationale
if constexpr (!(std::is_same_v<TIn, XRPAmount> ||
if constexpr (!(std::is_same_v<TIn, BRTAmount> ||
std::is_same_v<TOut, IOUAmount>))
return shouldRmSmallIncreasedQOffer<IOUAmount, XRPAmount>();
return shouldRmSmallIncreasedQOffer<IOUAmount, BRTAmount>();
}
if (!inIsXRP && !outIsXRP)
{
// See comment above for `if constexpr` rationale
if constexpr (!(std::is_same_v<TIn, XRPAmount> ||
std::is_same_v<TOut, XRPAmount>))
if constexpr (!(std::is_same_v<TIn, BRTAmount> ||
std::is_same_v<TOut, BRTAmount>))
return shouldRmSmallIncreasedQOffer<IOUAmount, IOUAmount>();
}
assert(0); // xrp/xrp offer!?! should never happen
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/basics/BRTAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ class BRTAmount : private boost::totally_ordered<BRTAmount>,
return s;
}

static XRPAmount
static BRTAmount
minPositiveAmount()
{
return XRPAmount{1};
return BRTAmount{1};
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/ripple/protocol/AmountConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ toAmount<IOUAmount>(IOUAmount const& amt)

template <class T>
T
toAmount(XRPAmount const& amt) = delete;
toAmount(BRTAmount const& amt) = delete;

template <>
inline XRPAmount
toAmount<XRPAmount>(XRPAmount const& amt)
inline BRTAmount
toAmount<BRTAmount>(BRTAmount const& amt)
{
return amt;
}
Expand Down

0 comments on commit 5bda54d

Please sign in to comment.