@@ -885,29 +885,26 @@ static void GetWalletBalances(UniValue& result)
885
885
}
886
886
887
887
/* *
888
- * GetProgressBar get a progress bar. The increment of the progress bar is 5% .
888
+ * GetProgressBar constructs a progress bar with 5% intervals .
889
889
*
890
- * @param progress The fraction of the progress bar to be filled. Min: 0.0, max: 1.0 .
891
- * @returns a string representation of the progress bar.
890
+ * @param[in] progress The proportion of the progress bar to be filled between 0 and 1 .
891
+ * @param[out] progress_bar String representation of the progress bar.
892
892
*/
893
- static std::string GetProgressBar (const double progress)
893
+ void GetProgressBar (double progress, std::string& progress_bar )
894
894
{
895
- if (progress < 0 || progress > 1 ) return " " ;
895
+ if (progress < 0 || progress > 1 ) return ;
896
896
897
- std::string progress_bar = " " ;
898
897
static constexpr double INCREMENT{0.05 };
899
898
static const std::string COMPLETE_BAR{" \u2592 " };
900
899
static const std::string INCOMPLETE_BAR{" \u2591 " };
901
900
902
- for (int i = 0 ; i < progress / INCREMENT; i++ ) {
901
+ for (int i = 0 ; i < progress / INCREMENT; ++i ) {
903
902
progress_bar += COMPLETE_BAR;
904
903
}
905
-
906
- for (int i = 0 ; i < (1 - progress) / INCREMENT; i++) {
904
+ for (int i = 0 ; i < (1 - progress) / INCREMENT; ++i) {
907
905
progress_bar += INCOMPLETE_BAR;
908
906
}
909
-
910
- return progress_bar;
907
+ progress_bar += " " ;
911
908
}
912
909
913
910
/* *
@@ -953,12 +950,12 @@ static void ParseGetInfoResult(UniValue& result)
953
950
result_string += strprintf (" Blocks: %s\n " , result[" blocks" ].getValStr ());
954
951
result_string += strprintf (" Headers: %s\n " , result[" headers" ].getValStr ());
955
952
956
- const double verification_progress {result[" verificationprogress" ].get_real ()};
957
- std::string verification_progress_bar = " " ;
958
- // Only display progress bar if < 99%
959
- if (verification_progress < 0.99 ) verification_progress_bar = GetProgressBar (verification_progress );
953
+ const double ibd_progress {result[" verificationprogress" ].get_real ()};
954
+ std::string ibd_progress_bar ;
955
+ // Display the progress bar only if IBD progress is less than 99%
956
+ if (ibd_progress < 0.99 ) GetProgressBar (ibd_progress, ibd_progress_bar );
960
957
961
- result_string += strprintf (" Verification progress: %s%.4f%%\n " , verification_progress_bar, verification_progress * 100 );
958
+ result_string += strprintf (" Verification progress: %s%.4f%%\n " , ibd_progress_bar, ibd_progress * 100 );
962
959
result_string += strprintf (" Difficulty: %s\n\n " , result[" difficulty" ].getValStr ());
963
960
964
961
result_string += strprintf (
0 commit comments