MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetProgressBar

Function GetProgressBar

src/bitcoin-cli.cpp:927–942  ·  view source on GitHub ↗

* GetProgressBar constructs a progress bar with 5% intervals. * * @param[in] progress The proportion of the progress bar to be filled between 0 and 1. * @param[out] progress_bar String representation of the progress bar. */

Source from the content-addressed store, hash-verified

925 * @param[out] progress_bar String representation of the progress bar.
926 */
927static void GetProgressBar(double progress, std::string& progress_bar)
928{
929 if (progress < 0 || progress > 1) return;
930
931 static constexpr double INCREMENT{0.05};
932 static const std::string COMPLETE_BAR{"\u2592"};
933 static const std::string INCOMPLETE_BAR{"\u2591"};
934
935 for (int i = 0; i < progress / INCREMENT; ++i) {
936 progress_bar += COMPLETE_BAR;
937 }
938
939 for (int i = 0; i < (1 - progress) / INCREMENT; ++i) {
940 progress_bar += INCOMPLETE_BAR;
941 }
942}
943
944/**
945 * ParseGetInfoResult takes in -getinfo result in UniValue object and parses it

Callers 1

ParseGetInfoResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected