Replace HexBits with strprintf #4422

pull jtimon wants to merge 1 commits into bitcoin:master from jtimon:hexstr changing 4 files +2 −13
  1. jtimon commented at 10:36 pm on June 26, 2014: contributor
    Get rid of HexBits.
  2. in src/miner.cpp: in 2f6718f5bd outdated
    412@@ -412,7 +413,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
    413 
    414     //// debug print
    415     LogPrintf("BitcoinMiner:\n");
    416-    LogPrintf("proof-of-work found  \n  hash: %s  \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
    417+    LogPrintf("proof-of-work found  \n  hash: %s  \ntarget: %s\n", pblock->GetHash().GetHex(), HexStr(pblock->nBits));
    


    sipa commented at 10:48 pm on June 26, 2014:
    Not that I care much about this debug output line but you’re aware pblock->nBits is not the same as hashTarget?
  3. in src/util.h: in 2f6718f5bd outdated
    281@@ -282,6 +282,17 @@ inline std::string HexStr(const T& vch, bool fSpaces=false)
    282     return HexStr(vch.begin(), vch.end(), fSpaces);
    283 }
    284 
    285+template<>
    286+inline std::string HexStr<unsigned int>(const unsigned int& nBits, bool fSpaces)
    


    laanwj commented at 8:27 am on June 27, 2014:
    What about just strprintf("%08x", nBits)?
  4. jtimon commented at 10:56 am on June 27, 2014: contributor
    @sipa I assumed HexStr(pblock->nBits) was going to be equivalent to uint256().SetCompact(pblock->nBits).GetHex() but I didn’t tested the output. I can leave as it was. @laanwj using strprintf("%08x", nBits) to replace HexBits instead of defining the new specialized HexStr seems better (less additions, the same deletions) if the outputs are equivalent. Would this serve for the case sipa is discussing too? Either way seems better to remove HexBits, which is just too specific.
  5. laanwj commented at 11:00 am on June 27, 2014: member
    @jtimon No, it wouldn’t address sipa’s problem. Let’s leave the line in CheckWork as it is, as I see it it doesn’t even use hexbits?
  6. jtimon commented at 11:22 am on June 27, 2014: contributor
    No, it doesn’t, I thought that could be a use outside of the rpc stuff, but yeah, I’ll just leave it as it was. Replace HexBits( with strprintf("%08x", it is.
  7. jtimon renamed this:
    Replace HexBits with HexStr template specialization
    Replace HexBits with strprintf
    on Jun 27, 2014
  8. laanwj commented at 11:40 am on June 27, 2014: member
    OK! We indeed still have to check that the output is the same, but looking at the source code the intention is the same. Ie, write the bytes of 0xAABBCCDD as AA BB CC DD in memory using htonl then print them as hex bytes, resulting in AABBCCDD.
  9. sipa commented at 11:41 am on June 27, 2014: member
    Untested ACK.
  10. jtimon commented at 11:43 am on June 27, 2014: contributor
    Yep, this won’t show up on the automatic tests so it will need to be tested manually.
  11. jgarzik commented at 1:35 pm on June 27, 2014: contributor
    u-t ACK
  12. jtimon commented at 5:53 pm on June 27, 2014: contributor
    Tested both functions in an independent program and they produce the same results.
  13. ghost commented at 6:58 pm on June 27, 2014: none
    ACK
  14. Replace HexBits with strprintf 645d497aa0
  15. BitcoinPullTester commented at 12:28 pm on June 28, 2014: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4422_645d497aa0010525441ce409e8e6d327a157ab39/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
  16. laanwj merged this on Jun 28, 2014
  17. laanwj closed this on Jun 28, 2014

  18. laanwj referenced this in commit f62784f961 on Jun 28, 2014
  19. jtimon deleted the branch on Jun 28, 2014
  20. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me