diff options
| author | Riccardo Spagni <ric@spagni.net> | 2019-04-15 09:18:10 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2019-04-15 09:18:10 +0200 |
| commit | 9bd0983d5eee1f422bad4d920ab78c70c8e6faeb (patch) | |
| tree | 2e599a575c50a17043c279942a88468cce6098ab /src/cryptonote_basic/difficulty.cpp | |
| parent | e31559d3199552adbf5c57216633405923148be4 (diff) | |
| parent | cbf3224180380d7ff2b4fc28b3800486f22a1cc7 (diff) | |
| download | monzero-core-9bd0983d5eee1f422bad4d920ab78c70c8e6faeb.tar.gz monzero-core-9bd0983d5eee1f422bad4d920ab78c70c8e6faeb.tar.xz monzero-core-9bd0983d5eee1f422bad4d920ab78c70c8e6faeb.zip | |
Merge pull request #5402
cbf32241 rpc: make wide_difficulty hexadecimal (moneromooo-monero)
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; + } + } |
