Skip to content

Commit

Permalink
rename 'missingCoins' field to 'shortfall' in the MA selection change…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
KtorZ committed Jan 27, 2021
1 parent 2650cff commit b34a575
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -2785,7 +2785,7 @@ instance LiftHandler ErrSelectAssets where
[ "I am unable to finalize the transaction as there are "
, "not enough Ada I can use to pay for either fees, or "
, "minimum Ada value in change outputs. I need about "
, pretty (missingCoins e), " Ada to proceed; try "
, pretty (shortfall e), " Ada to proceed; try "
, "increasing your wallet balance as such, or try "
, "sending a different, smaller payment."
]
Expand Down
Expand Up @@ -231,9 +231,9 @@ buildSelectionResult
-> Builder
buildSelectionResult changeF s@SelectionResult{inputsSelected,extraCoinSource} =
mconcat
[ nameF "inputs selected" (inputsF inputsSelected)
[ nameF "inputs selected" (inputsF inputsSelected)
, nameF "extra coin input" (build extraCoinSource)
, nameF "outputs covered" (build $ outputsCovered s)
, nameF "outputs covered" (build $ outputsCovered s)
, nameF "change generated" (changeF $ changeGenerated s)
, nameF "size utxo remaining" (build $ UTxOIndex.size $ utxoRemaining s)
]
Expand Down Expand Up @@ -318,7 +318,7 @@ data UnableToConstructChangeError = UnableToConstructChangeError
:: !Coin
-- ^ The minimal required cost needed for the transaction to be
-- considered valid. This does not include min Ada values.
, missingCoins
, shortfall
:: !Coin
-- ^ The additional coin quantity that would be required to cover the
-- selection cost and minimum coin quantity of each change output.
Expand Down Expand Up @@ -588,10 +588,10 @@ runSelection limit mExtraCoinSource available minimumBalance =
, leftover = available
}

-- NOTE: We run the 'coinSelector' last, because we know that there are
-- necessarily coins in all inputs. Therefore, after having ran the other
-- selectors, we may already have covered for coins and need not to select
-- extra inputs.
-- NOTE: We run the 'coinSelector' last, because we know that every input
-- necessarily has a non-zero ada amount. By running the other selectors
-- first, we increase the probability that the coin selector will be able
-- to terminate without needing to select an additional coin.
selectors :: [SelectionState -> m (Maybe SelectionState)]
selectors =
reverse (coinSelector : fmap assetSelector minimumAssetQuantities)
Expand Down Expand Up @@ -839,7 +839,7 @@ makeChange minCoinValueFor requiredCost mExtraCoinSource inputBundles outputBund
changeError excessCoin change =
UnableToConstructChangeError
{ requiredCost
, missingCoins =
, shortfall =
-- This conversion is safe because we know that the distance is
-- small-ish. If it wasn't, we would have have enough coins to
-- construct the change.
Expand Down
Expand Up @@ -612,7 +612,7 @@ prop_performSelection minCoinValueFor costFor (Blind criteria) coverage =

onUnableToConstructChange e = do
monitor $ counterexample $ show e
assert (missingCoins e > Coin 0)
assert (shortfall e > Coin 0)
let criteria' = criteria { selectionLimit = NoLimit }
run (performSelection noMinCoin (const noCost) criteria') >>= \case
Left e' -> do
Expand Down

0 comments on commit b34a575

Please sign in to comment.