special case DoS value == 0 #3047

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:misbehave changing 1 files +4 −4
  1. Diapolo commented at 2:30 PM on October 1, 2013: none
    • prevents unneeded log messages, which could make users think something bad was happening
  2. gavinandresen commented at 4:32 AM on October 4, 2013: contributor

    NACK on the else if (howmuch == 0). That is dead code, because the only two places Misbehaving(0) can happen are the two places where you put checks to not call Misbehaving in the first place.

    Either keep the checks, or just have Misbehaving(0) simply do if howmuch == 0 return;

  3. special case DoS value == 0 in ProcessMessage()
    - prevents unneeded log messages, which could make users think something
      bad was happening
    fbed9c9d63
  4. Diapolo commented at 8:13 AM on October 4, 2013: none

    @gavinandresen Updated and removed the else if (howmuch == 0). Should be fine now.

  5. sipa commented at 8:35 AM on October 4, 2013: member

    ACK

  6. BitcoinPullTester commented at 10:03 AM on October 4, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/fbed9c9d6356f86e5507b3fc032f263a17137d57 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.

  7. laanwj commented at 10:07 AM on October 4, 2013: member

    ACK

    Though I must say the code is a bit confusing to read. The argument of state.IsInvalid(nDoS) is an inout argument which is then checked in the same if() clause.

  8. gavinandresen referenced this in commit 15b48ab036 on Oct 4, 2013
  9. gavinandresen merged this on Oct 4, 2013
  10. gavinandresen closed this on Oct 4, 2013

  11. Diapolo commented at 12:08 PM on October 6, 2013: none

    You were thinking of this?

    <pre> int nDoS = 0; if (state.IsInvalid(nDoS)) if (nDoS > 0) pfrom->Misbehaving(nDoS); </pre>

    Yeah would be easier to read...

  12. laanwj commented at 6:38 AM on October 7, 2013: member

    @Diapolo Yes, I'd prefer something like that, as it gives more of a signal to the reader that nDOS is the result of the state.IsInvalid() call. Now they could think 'hey, it's never >0, let's cut that code out!', but never mind this is just bikeshedding...

  13. Diapolo commented at 6:57 AM on October 7, 2013: none

    You know I take such comments very seriously and created #3064 to address it :).

  14. Bushstar referenced this in commit 4a7525da38 on Apr 8, 2020
  15. Bushstar referenced this in commit 2e0cf8a30b on Apr 8, 2020
  16. DrahtBot 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: 2026-04-17 18:15 UTC

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