[rpc] mining: Omit uninitialized currentblockweight, currentblocktx #15383

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1902-rpcMining changing 7 files +62 −39
  1. MarcoFalke commented at 4:34 pm on February 11, 2019: member
    Previously we’d report “0”, which could be mistaken for a valid number. E.g. the number of transactions is 0 or the block weight is 0, whatever that means.
  2. MarcoFalke added the label Docs on Feb 11, 2019
  3. MarcoFalke added the label RPC/REST/ZMQ on Feb 11, 2019
  4. MarcoFalke added the label Mining on Feb 11, 2019
  5. MarcoFalke renamed this:
    [rpc] mining: Report -1 for uninitialized currentblockweight and currentblocktx
    [rpc] mining: Report -1 for uninitialized currentblockweight, currentblocktx
    on Feb 11, 2019
  6. MarcoFalke force-pushed on Feb 11, 2019
  7. benthecarman commented at 7:14 pm on February 11, 2019: contributor
    This should probably have release notes
  8. MarcoFalke commented at 7:29 pm on February 11, 2019: member
    I am happy to write them after this is merged
  9. MarcoFalke added the label Needs release note on Feb 11, 2019
  10. in src/rpc/mining.cpp:198 in fabf7eb89b outdated
    204-            "  \"chain\": \"xxxx\",           (string) current network name as defined in BIP70 (main, test, regtest)\n"
    205-            "  \"warnings\": \"...\"          (string) any network and blockchain warnings\n"
    206-            "}\n"
    207+                    "{\n"
    208+                    "  \"blocks\": nnn,             (numeric) The current block\n"
    209+                    "  \"currentblockweight\": nnn, (numeric) The block weight of the last assembled block (or -1 if no block was ever assembled)\n"
    


    promag commented at 7:51 pm on February 11, 2019:
    Just noting that we could omit these keys instead of -1.

    MarcoFalke commented at 7:55 pm on February 11, 2019:
    Or set the value to json-null
  11. promag commented at 7:54 pm on February 11, 2019: member
    Concept ACK, change looks good too. Could have a test for -1 values?
  12. practicalswift commented at 8:23 pm on February 11, 2019: contributor

    Looks good but nLastBlockTx and nLastBlockWeight should be removed from miner.cpp too?

    0$ git grep -E 'nLastBlockTx|nLastBlockWeight'
    1src/miner.cpp:uint64_t nLastBlockTx = 0;
    2src/miner.cpp:uint64_t nLastBlockWeight = 0;
    
  13. MarcoFalke force-pushed on Feb 11, 2019
  14. MarcoFalke renamed this:
    [rpc] mining: Report -1 for uninitialized currentblockweight, currentblocktx
    [rpc] mining: Report null for uninitialized currentblockweight, currentblocktx
    on Feb 11, 2019
  15. MarcoFalke removed the label Needs release note on Feb 11, 2019
  16. MarcoFalke commented at 9:15 pm on February 11, 2019: member
    Added release notes, removed leftover variables, run clang format, … Should be ready
  17. MarcoFalke force-pushed on Feb 11, 2019
  18. promag commented at 9:30 pm on February 11, 2019: member
    @MarcoFalke could test null values now?
  19. MarcoFalke force-pushed on Feb 11, 2019
  20. in src/rpc/mining.cpp:198 in fa3c0daaf1 outdated
    204-            "  \"chain\": \"xxxx\",           (string) current network name as defined in BIP70 (main, test, regtest)\n"
    205-            "  \"warnings\": \"...\"          (string) any network and blockchain warnings\n"
    206-            "}\n"
    207+                    "{\n"
    208+                    "  \"blocks\": nnn,             (numeric) The current block\n"
    209+                    "  \"currentblockweight\": nnn, (numeric) The block weight of the last assembled block (or 'null' if no block was ever assembled)\n"
    


    fanquake commented at 11:21 pm on February 11, 2019:
    (numeric, optional) for both?

    MarcoFalke commented at 11:28 pm on February 11, 2019:

    They are not optional in a sense that they could be omitted.

    The type is either numeric or null-type, but I don’t think we document this in other places


    promag commented at 11:39 pm on February 11, 2019:
    Yap, they are always present, so not optional.
  21. benthecarman deleted a comment on Feb 11, 2019
  22. luke-jr commented at 0:37 am on February 12, 2019: member
    Why not omit the fields entirely?
  23. gmaxwell commented at 1:14 am on February 12, 2019: contributor
    Omitting the fields was also my intuition (just going off the first line of the PR description). It’s true that some software might not handle omitted fields well, but the same stuff would probably not handle the special json null either.
  24. in doc/release-notes.md:267 in fa3c0daaf1 outdated
    262@@ -263,6 +263,9 @@ in the Low-level Changes section below.
    263 
    264 - See the [Mining](#mining) section for changes to `getblocktemplate`.
    265 
    266+- The `getmininginfo` RPC now returns `null` for `currentblockweight` and
    267+  `currentblocktx` when a block was never assembled via an RPC on this node.
    


    promag commented at 3:38 pm on February 12, 2019:
    nit, just “via RPC”?
  25. promag commented at 3:40 pm on February 12, 2019: member

    @luke-jr @gmaxwell it was suggested before #15383 (review). Since it’s an edge case, once set it’s always present, I tend to prefer null value.

    utACK fa3c0da.

  26. [rpc] mining: Omit uninitialized currentblockweight, currentblocktx fa178a6385
  27. MarcoFalke force-pushed on Feb 12, 2019
  28. MarcoFalke renamed this:
    [rpc] mining: Report null for uninitialized currentblockweight, currentblocktx
    [rpc] mining: Omit uninitialized currentblockweight, currentblocktx
    on Feb 12, 2019
  29. MarcoFalke commented at 4:37 pm on February 12, 2019: member
    Made it to omit the key-value altogether
  30. promag commented at 4:43 pm on February 12, 2019: member
    utACK fa178a6.
  31. MarcoFalke added this to the milestone 0.18.0 on Feb 12, 2019
  32. laanwj commented at 4:55 pm on February 12, 2019: member
    Concept ACK
  33. MarcoFalke referenced this in commit eca1273c35 on Feb 15, 2019
  34. MarcoFalke merged this on Feb 15, 2019
  35. MarcoFalke closed this on Feb 15, 2019

  36. MarcoFalke deleted the branch on Feb 15, 2019
  37. deadalnix referenced this in commit e04b854d9b on May 4, 2020
  38. MarcoFalke locked this on Dec 16, 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-21 09:12 UTC

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