diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-05 16:28:15 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-05 16:30:16 +0000 |
commit | cbf3224180380d7ff2b4fc28b3800486f22a1cc7 (patch) | |
tree | 9f2d6b4de0d6e2dc3e2e30c4472fe1d19d97a4ed /src/cryptonote_basic/difficulty.cpp | |
parent | Merge pull request #5390 (diff) | |
download | monero-cbf3224180380d7ff2b4fc28b3800486f22a1cc7.tar.xz |
rpc: make wide_difficulty hexadecimal
This should be friendlier for clients which don't have bignum support
Diffstat (limited to 'src/cryptonote_basic/difficulty.cpp')
-rw-r--r-- | src/cryptonote_basic/difficulty.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index 5162e53e6..859173aa5 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -239,4 +239,19 @@ namespace cryptonote { return res.convert_to<difficulty_type>(); } + std::string hex(difficulty_type v) + { + static const char chars[] = "0123456789abcdef"; + std::string s; + while (v > 0) + { + s.push_back(chars[(v & 0xf).convert_to<unsigned>()]); + v >>= 4; + } + if (s.empty()) + s += "0"; + std::reverse(s.begin(), s.end()); + return "0x" + s; + } + } |