From 43f30d941405626a4d0f542f3a0e81627a9fa397 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Thu, 18 Jan 2024 11:20:54 +0100 Subject: [PATCH 1/4] Frontend.Console: show progress on balance check Show progress when checking balances so that we can know which currency is the slow one. Fixes https://github.com/nblockchain/geewallet/issues/245 --- src/GWallet.Frontend.Console/Program.fs | 3 ++- src/GWallet.Frontend.Console/UserInteraction.fs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GWallet.Frontend.Console/Program.fs b/src/GWallet.Frontend.Console/Program.fs index 034427b5e..e8c61ff87 100644 --- a/src/GWallet.Frontend.Console/Program.fs +++ b/src/GWallet.Frontend.Console/Program.fs @@ -467,10 +467,11 @@ let rec ProgramMainLoop() = ) Console.WriteLine () - Console.WriteLine "*** STATUS ***" + Console.WriteLine("*** STATUS ***" + Environment.NewLine) let lines = UserInteraction.DisplayAccountStatuses(WhichAccount.All activeAccounts) |> Async.RunSynchronously + Console.WriteLine Environment.NewLine Console.WriteLine (String.concat Environment.NewLine lines) Console.WriteLine () diff --git a/src/GWallet.Frontend.Console/UserInteraction.fs b/src/GWallet.Frontend.Console/UserInteraction.fs index daa6c54ae..0825a5fdf 100644 --- a/src/GWallet.Frontend.Console/UserInteraction.fs +++ b/src/GWallet.Frontend.Console/UserInteraction.fs @@ -251,6 +251,9 @@ module UserInteraction = // so that, in case balance retrieval is faster than FiatValEstimation, and the balance is zero, then // we don't need to query the fiat value at all (micro-optimization?) let! balance,usdValue = FSharpUtil.AsyncExtensions.MixedParallel2 balanceJob usdValueJob + + Console.Write account.Currency + Console.Write ' ' return (account,balance,usdValue) } @@ -264,6 +267,7 @@ module UserInteraction = let private GetAccountBalances (accounts: seq) : Async*MaybeCached>> = let accountAndBalancesToBeQueried = accounts |> Seq.map GetAccountBalanceInner + Console.Write "Retrieving balances... " Async.Parallel accountAndBalancesToBeQueried let DisplayAccountStatuses(whichAccount: WhichAccount): Async> = From e867a9b9f1678796758ebb26a44e88b901203c18 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Thu, 18 Jan 2024 13:06:53 +0100 Subject: [PATCH 2/4] Frontend.Console: print dot at the end Print dot at the end of "Retrieving balances... " line after all currency names are printed. --- src/GWallet.Frontend.Console/UserInteraction.fs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/GWallet.Frontend.Console/UserInteraction.fs b/src/GWallet.Frontend.Console/UserInteraction.fs index 0825a5fdf..21742ccaa 100644 --- a/src/GWallet.Frontend.Console/UserInteraction.fs +++ b/src/GWallet.Frontend.Console/UserInteraction.fs @@ -252,8 +252,8 @@ module UserInteraction = // we don't need to query the fiat value at all (micro-optimization?) let! balance,usdValue = FSharpUtil.AsyncExtensions.MixedParallel2 balanceJob usdValueJob - Console.Write account.Currency Console.Write ' ' + Console.Write account.Currency return (account,balance,usdValue) } @@ -267,7 +267,7 @@ module UserInteraction = let private GetAccountBalances (accounts: seq) : Async*MaybeCached>> = let accountAndBalancesToBeQueried = accounts |> Seq.map GetAccountBalanceInner - Console.Write "Retrieving balances... " + Console.Write "Retrieving balances..." Async.Parallel accountAndBalancesToBeQueried let DisplayAccountStatuses(whichAccount: WhichAccount): Async> = @@ -347,6 +347,9 @@ module UserInteraction = let! accountsWithBalances = GetAccountBalances accounts let statuses, currencyTotals = displayAllAndSumBalance accountsWithBalances 0 Map.empty + // All balances are fetched and their currency names printed, put a dot at the end of "Retrieving balances... " line. + Console.Write '.' + let maybeTotalInUsd, totals = displayTotalAndSumFiatBalance currencyTotals return seq { From feb5e94087ad112376cf15bf1019c3bc0786b557 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 19 Jan 2024 13:50:00 +0800 Subject: [PATCH 3/4] Frontend.Console: consistently cosmetic --- src/GWallet.Frontend.Console/Program.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/GWallet.Frontend.Console/Program.fs b/src/GWallet.Frontend.Console/Program.fs index e8c61ff87..e92145193 100644 --- a/src/GWallet.Frontend.Console/Program.fs +++ b/src/GWallet.Frontend.Console/Program.fs @@ -467,7 +467,9 @@ let rec ProgramMainLoop() = ) Console.WriteLine () - Console.WriteLine("*** STATUS ***" + Environment.NewLine) + Console.WriteLine "*** STATUS ***" + Console.WriteLine () + let lines = UserInteraction.DisplayAccountStatuses(WhichAccount.All activeAccounts) |> Async.RunSynchronously From 9b05581227cd453212911054e958ef63c869f47a Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 19 Jan 2024 13:55:23 +0800 Subject: [PATCH 4/4] Frontend.Console: prevent possible ConsoleOut race By separating both writes, it could happen that two spaces get written consecutively, instead of concatenating the spaces with the currency first. --- src/GWallet.Frontend.Console/UserInteraction.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GWallet.Frontend.Console/UserInteraction.fs b/src/GWallet.Frontend.Console/UserInteraction.fs index 21742ccaa..b27d71332 100644 --- a/src/GWallet.Frontend.Console/UserInteraction.fs +++ b/src/GWallet.Frontend.Console/UserInteraction.fs @@ -251,9 +251,9 @@ module UserInteraction = // so that, in case balance retrieval is faster than FiatValEstimation, and the balance is zero, then // we don't need to query the fiat value at all (micro-optimization?) let! balance,usdValue = FSharpUtil.AsyncExtensions.MixedParallel2 balanceJob usdValueJob - - Console.Write ' ' - Console.Write account.Currency + + let progressIteration = sprintf " %A" account.Currency + Console.Write progressIteration return (account,balance,usdValue) }