From 33abcfd4dcb7b11745e6c6fa6da1858943005708 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 22 Feb 2016 23:31:21 +0100 Subject: remove excessive logging --- extension/lib/wallet/types.ts | 86 ++++++++++++++++++------------------------ extension/lib/wallet/wallet.ts | 10 ----- 2 files changed, 36 insertions(+), 60 deletions(-) (limited to 'extension') diff --git a/extension/lib/wallet/types.ts b/extension/lib/wallet/types.ts index 8151bf41a..88b55f918 100644 --- a/extension/lib/wallet/types.ts +++ b/extension/lib/wallet/types.ts @@ -175,30 +175,24 @@ export namespace Amounts { } export function add(first: AmountJson, ...rest: AmountJson[]): Result { - const doit = () => { - let currency = first.currency; - let value = first.value + Math.floor(first.fraction / 1e6); + let currency = first.currency; + let value = first.value + Math.floor(first.fraction / 1e6); + if (value > Number.MAX_SAFE_INTEGER) { + return {amount: getMaxAmount(currency), saturated: true}; + } + let fraction = first.fraction % 1e6; + for (let x of rest) { + if (x.currency !== currency) { + throw Error(`Mismatched currency: ${x.currency} and ${currency}`); + } + + value = value + x.value + Math.floor((fraction + x.fraction) / 1e6); + fraction = (fraction + x.fraction) % 1e6; if (value > Number.MAX_SAFE_INTEGER) { return {amount: getMaxAmount(currency), saturated: true}; } - let fraction = first.fraction % 1e6; - for (let x of rest) { - if (x.currency !== currency) { - throw Error(`Mismatched currency: ${x.currency} and ${currency}`); - } - - value = value + x.value + Math.floor((fraction + x.fraction) / 1e6); - fraction = (fraction + x.fraction) % 1e6; - if (value > Number.MAX_SAFE_INTEGER) { - return {amount: getMaxAmount(currency), saturated: true}; - } - } - return {amount: {currency, value, fraction}, saturated: false}; - }; - console.log("adding", first, "and", rest); - let ret = doit(); - console.log("result is", ret); - return ret; + } + return {amount: {currency, value, fraction}, saturated: false}; } @@ -226,35 +220,27 @@ export namespace Amounts { } export function cmp(a: AmountJson, b: AmountJson): number { - const doit = () => { - if (a.currency !== b.currency) { - throw Error(`Mismatched currency: ${a.currency} and ${b.currency}`); - } - let av = a.value + Math.floor(a.fraction / 1e6); - let af = a.fraction % 1e6; - let bv = b.value + Math.floor(b.fraction / 1e6); - let bf = b.fraction % 1e6; - switch (true) { - case av < bv: - return -1; - case av > bv: - return 1; - case af < bf: - return -1; - case af > bf: - return 1; - case af == bf: - return 0; - default: - throw Error("assertion failed"); - } - }; - - console.log("comparing", a, "and", b); - let res = doit(); - console.log("result:", res); - return res; - + if (a.currency !== b.currency) { + throw Error(`Mismatched currency: ${a.currency} and ${b.currency}`); + } + let av = a.value + Math.floor(a.fraction / 1e6); + let af = a.fraction % 1e6; + let bv = b.value + Math.floor(b.fraction / 1e6); + let bf = b.fraction % 1e6; + switch (true) { + case av < bv: + return -1; + case av > bv: + return 1; + case af < bf: + return -1; + case af > bf: + return 1; + case af == bf: + return 0; + default: + throw Error("assertion failed"); + } } export function copy(a: AmountJson): AmountJson { diff --git a/extension/lib/wallet/wallet.ts b/extension/lib/wallet/wallet.ts index 76339fe5d..67e35bd11 100644 --- a/extension/lib/wallet/wallet.ts +++ b/extension/lib/wallet/wallet.ts @@ -356,10 +356,6 @@ function getWithdrawDenomList(amountAvailable: AmountJson, denoms = denoms.filter(isWithdrawableDenom); denoms.sort((d1, d2) => Amounts.cmp(d2.value, d1.value)); - console.log("ranked denoms"); - console.dir(denoms); - - // This is an arbitrary number of coins // we can withdraw in one go. It's not clear if this limit // is useful ... @@ -376,7 +372,6 @@ function getWithdrawDenomList(amountAvailable: AmountJson, break; } if (!found) { - console.log("did not find coins for remaining ", remaining); break; } } @@ -561,7 +556,6 @@ export class Wallet { error: "coins-insufficient", }; } - console.log("about to record ..."); let mintUrl = Object.keys(mcs)[0]; return this.cryptoApi.signDeposit(offer, mcs[mintUrl]) @@ -848,8 +842,6 @@ export class Wallet { .map((d: Denomination) => Amounts.add(d.value, d.fee_withdraw).amount) .reduce((a, b) => Amounts.add(a, b).amount); - console.log("actual coin cost", actualCoinCost); - console.log("amount", amount); let ret: ReserveCreationInfo = { mintInfo, selectedDenoms, @@ -877,8 +869,6 @@ export class Wallet { return Query(this.db).get("mints", baseUrl).then((r) => { let mintInfo; - - console.log("got mints result"); console.dir(r); if (!r) { -- cgit v1.2.3