Remove unnecessary pow updates in rpc #4393

pull jtimon wants to merge 1 commits into bitcoin:master from jtimon:rpcpow changing 1 files +0 −4
  1. jtimon commented at 1:45 pm on June 23, 2014: contributor
    The time is already set in CreateNewBlock and the nonce is set to zero for no reason (never used after that assignment). In testnet mode the nbits (and thefore target, which is the same with another type) could be affected in testnet mode after finding the block with that additional UpdateTime (which may update nBits), which doesn’t seem very safe. This is not tested yet, but seems straightforward to review and test.
  2. Remove unnecessary pow updates in rpc 8ec7329807
  3. jtimon commented at 10:42 am on June 25, 2014: contributor

    This is not as risky as it may look like, in fact I think it is pretty save and if anything the previous behavior is the wrong one (not saying it doesn’t need testing).

    How much time can pass from https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp#L308 (called from https://github.com/bitcoin/bitcoin/blob/master/src/rpcmining.cpp#L359) to https://github.com/bitcoin/bitcoin/blob/master/src/rpcmining.cpp#L369 ? The nonce is set to zero in both cases and the bits can only change in the second UpdateTime if we’re on testnet.

  4. sipa commented at 10:49 am on June 25, 2014: member
    Untested ACK. Those calls look redundant.
  5. BitcoinPullTester commented at 9:35 pm on June 25, 2014: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4393_8ec7329807a6ce96188c6e6dd3af84602499b07f/ 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.
  6. jgarzik commented at 2:07 pm on June 26, 2014: contributor
    NAK. Obviously wrong. Read the code. If called frequently, those static vars act as a cache.
  7. jtimon commented at 2:19 pm on June 26, 2014: contributor
    I see, so removing this would cause the cached nTime to be used. I think removing the nNonce = 0 assignment is safe though, no? A cached zero should be as good as a fresh one.
  8. jtimon closed this on Jun 26, 2014

  9. sipa commented at 5:16 pm on June 26, 2014: member
    Undo ACK; You’re right, @jgarzik.
  10. jtimon deleted the branch on Jun 26, 2014
  11. laanwj commented at 8:12 am on June 27, 2014: member
    Sharp catch @jgarzik
  12. 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-12-19 03:12 UTC

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