refactor: Call type-solver earlier in decodescript #23642

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2112-rpcRefDec changing 1 files +31 −32
  1. MarcoFalke commented at 10:12 AM on December 1, 2021: member

    The current logic is a bit confusing. First creating the UniValue return dict, then parsing it again to get the type as std::string.

    Clean this up by using a strong type TxoutType. Also, remove whitespace.

  2. style: Remove whitespace
    Can be reviewed via --ignore-all-space
    fab0d998f4
  3. refactor: Call type-solver earlier in decodescript
    Also, remove std::string type.
    3333070208
  4. MarcoFalke added the label Refactoring on Dec 1, 2021
  5. MarcoFalke added the label RPC/REST/ZMQ on Dec 1, 2021
  6. shaavan approved
  7. shaavan commented at 11:15 AM on December 1, 2021: contributor

    ACK 33330702081f67cb05fd86e00b252f6355249513

    The refactoring looks good, and I find it an improvement over the current master’s code. This PR removes the extra steps of:

    1. Searching for the ‘type’ value of the script and changing it to str, and,
    2. Checking and comparing the type values in str format.

    Instead, this PR directly creates a TxoutType object corresponding to the script and compares the result with the enum values of the TxoutType class, which was subsequently done even in the master branch’s case.

    The whitespace removal commit also looks good. I checked for any formatting issues, and I found none.

  8. DrahtBot commented at 1:11 PM on December 1, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #23545 (scripted-diff: Use clang-tidy syntax for C++ named arguments [WIP; TOO MANY CONFLICTS] by MarcoFalke)

    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.

  9. theStack commented at 7:08 PM on December 1, 2021: member

    Concept ACK on using the strong type TxoutType instead of strings. However, now the type-solving happens rather twice (once in ScriptPubKeyToUniv, a second time immediately after its call) rather than "earlier", isn't it? Not sure though if this is really a problem for the performance, probably the RPC call overhead is already an order of magnitude higher than the solving itself, so that it doesn't really matter if it's done twice.

  10. MarcoFalke commented at 7:51 AM on December 2, 2021: member

    Yes, I'd say it shouldn't matter performance wise. After all, it already happens twice on current master.

  11. theStack approved
  12. theStack commented at 12:48 PM on December 2, 2021: member

    Yes, I'd say it shouldn't matter performance wise. After all, it already happens twice on current master.

    Oh, nevermind, for some reason I didn't see the second solver call in master 🤦‍♂️

    Code-review ACK 33330702081f67cb05fd86e00b252f6355249513

  13. MarcoFalke referenced this in commit 0bd7ca9a03 on Dec 2, 2021
  14. MarcoFalke closed this on Dec 2, 2021

  15. MarcoFalke deleted the branch on Dec 2, 2021
  16. sidhujag referenced this in commit 2f3e4b502b on Dec 2, 2021
  17. RandyMcMillan referenced this in commit ea8e28bb33 on Dec 23, 2021
  18. DrahtBot locked this on Dec 2, 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: 2026-04-13 15:14 UTC

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