rest: Do not re-use the function name ParseHashStr (core_io.h) for a function with different behaviour in rest.cpp #14288

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:ParseHashStr-duplicate changing 1 files +4 −4
  1. practicalswift commented at 3:53 pm on September 21, 2018: contributor

    Do not re-use the function name ParseHashStr (core_io.h) for a function with different behaviour in rest.cpp.

    Before:

    0src/core_io.h:uint256 ParseHashStr(const std::string&, const std::string& strName);
    1src/core_read.cpp:uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
    2src/rest.cpp:static bool ParseHashStr(const std::string& strReq, uint256& v)
    

    After:

    0src/core_io.h:uint256 ParseHashStr(const std::string&, const std::string& strName);
    1src/core_read.cpp:uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
    
  2. rest: Do not re-use the function name ParseHashStr (core_io.h) for a function with different behaviour in rest.cpp 6f24de8cb2
  3. practicalswift force-pushed on Sep 21, 2018
  4. MarcoFalke commented at 4:05 pm on September 21, 2018: member
    Reminds me of “Drop ParseHashUV in favor of calling ParseHashStr” #13422 by @Empact
  5. MarcoFalke added the label Refactoring on Sep 21, 2018
  6. MarcoFalke added the label RPC/REST/ZMQ on Sep 21, 2018
  7. DrahtBot commented at 5:46 pm on September 21, 2018: member
    • #13815 (util: Add [[nodiscard]] to all {Decode,Parse} functions returning bool by practicalswift)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  8. l2a5b1 commented at 11:56 am on September 24, 2018: contributor
    I don’t mind the change, but also don’t mind keeping it as it is. :) I suspect either way is fine.
  9. MarcoFalke commented at 12:23 pm on September 24, 2018: member
    Couldn’t you remove this function and just call ParseHashStr?
  10. practicalswift commented at 1:09 pm on September 24, 2018: contributor

    @MarcoFalke Yes, but I don’t want to change any behaviour and the functions are not identical. ParseHashStr throws std::runtime_error in case of non-hex input which ParseHexHashStr does not. Also note the length requirement of ParseHexHashStr.

    0uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
    1{
    2    if (!IsHex(strHex)) // Note: IsHex("") is false
    3        throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
    4
    5    uint256 result;
    6    result.SetHex(strHex);
    7    return result;
    8}
    
    0// Suggested new function name: ParseHexHashStr
    1static bool ParseHashStr(const std::string& strReq, uint256& v)
    2{
    3    if (!IsHex(strReq) || (strReq.size() != 64))
    4        return false;
    5
    6    v.SetHex(strReq);
    7    return true;
    8}
    
  11. practicalswift commented at 3:40 pm on September 24, 2018: contributor
    Closing in favour of #14307 which fixes this issue more elegantly :-)
  12. practicalswift closed this on Sep 24, 2018

  13. MarcoFalke referenced this in commit 01211cea71 on Sep 27, 2018
  14. practicalswift deleted the branch on Apr 10, 2021
  15. pravblockc referenced this in commit a8f037c1a6 on Jul 30, 2021
  16. pravblockc referenced this in commit ba2ab9029a on Aug 3, 2021
  17. pravblockc referenced this in commit 67108d97c0 on Aug 4, 2021
  18. pravblockc referenced this in commit 6cfb76a0c4 on Aug 4, 2021
  19. pravblockc referenced this in commit 35e19528db on Aug 4, 2021
  20. pravblockc referenced this in commit 59ae41853b on Aug 4, 2021
  21. gades referenced this in commit 2bf05ef775 on May 4, 2022
  22. DrahtBot locked this on Aug 16, 2022

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-10-04 22:12 UTC

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