@@ -885,29 +885,26 @@ static void GetWalletBalances(UniValue& result)
885885}
886886
887887/* *
888- * GetProgressBar get a progress bar. The increment of the progress bar is 5% .
888+ * GetProgressBar constructs a progress bar with 5% intervals .
889889 *
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.
892892 */
893- static std::string GetProgressBar (const double progress)
893+ void GetProgressBar (double progress, std::string& progress_bar )
894894{
895- if (progress < 0 || progress > 1 ) return " " ;
895+ if (progress < 0 || progress > 1 ) return ;
896896
897- std::string progress_bar = " " ;
898897 static constexpr double INCREMENT{0.05 };
899898 static const std::string COMPLETE_BAR{" \u2592 " };
900899 static const std::string INCOMPLETE_BAR{" \u2591 " };
901900
902- for (int i = 0 ; i < progress / INCREMENT; i++ ) {
901+ for (int i = 0 ; i < progress / INCREMENT; ++i ) {
903902 progress_bar += COMPLETE_BAR;
904903 }
905-
906- for (int i = 0 ; i < (1 - progress) / INCREMENT; i++) {
904+ for (int i = 0 ; i < (1 - progress) / INCREMENT; ++i) {
907905 progress_bar += INCOMPLETE_BAR;
908906 }
909-
910- return progress_bar;
907+ progress_bar += " " ;
911908}
912909
913910/* *
@@ -953,12 +950,12 @@ static void ParseGetInfoResult(UniValue& result)
953950 result_string += strprintf (" Blocks: %s\n " , result[" blocks" ].getValStr ());
954951 result_string += strprintf (" Headers: %s\n " , result[" headers" ].getValStr ());
955952
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 );
960957
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 );
962959 result_string += strprintf (" Difficulty: %s\n\n " , result[" difficulty" ].getValStr ());
963960
964961 result_string += strprintf (
0 commit comments