From 645d497aa0010525441ce409e8e6d327a157ab39 Mon Sep 17 00:00:00 2001 From: jtimon Date: Fri, 27 Jun 2014 13:28:08 +0200 Subject: [PATCH] Replace HexBits with strprintf --- src/rpcblockchain.cpp | 2 +- src/rpcmining.cpp | 2 +- src/rpcserver.cpp | 10 ---------- src/rpcserver.h | 1 - 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 580c6bd5baf..a67f266a134 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -66,7 +66,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) result.push_back(Pair("tx", txs)); result.push_back(Pair("time", block.GetBlockTime())); result.push_back(Pair("nonce", (uint64_t)block.nNonce)); - result.push_back(Pair("bits", HexBits(block.nBits))); + result.push_back(Pair("bits", strprintf("%08x", block.nBits))); result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 98caf704eec..db60ef35926 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -443,7 +443,7 @@ Value getblocktemplate(const Array& params, bool fHelp) result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS)); result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE)); result.push_back(Pair("curtime", (int64_t)pblock->nTime)); - result.push_back(Pair("bits", HexBits(pblock->nBits))); + result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); return result; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 54043458d5f..6a87c8bf999 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -97,16 +97,6 @@ Value ValueFromAmount(int64_t amount) return (double)amount / (double)COIN; } -std::string HexBits(unsigned int nBits) -{ - union { - int32_t nBits; - char cBits[4]; - } uBits; - uBits.nBits = htonl((int32_t)nBits); - return HexStr(BEGIN(uBits.cBits), END(uBits.cBits)); -} - uint256 ParseHashV(const Value& v, string strName) { string strHex; diff --git a/src/rpcserver.h b/src/rpcserver.h index fcd293663ff..01e77163c4d 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -116,7 +116,6 @@ extern int64_t nWalletUnlockTime; extern int64_t AmountFromValue(const json_spirit::Value& value); extern json_spirit::Value ValueFromAmount(int64_t amount); extern double GetDifficulty(const CBlockIndex* blockindex = NULL); -extern std::string HexBits(unsigned int nBits); extern std::string HelpRequiringPassphrase(); extern std::string HelpExampleCli(std::string methodname, std::string args); extern std::string HelpExampleRpc(std::string methodname, std::string args);