test: Remove message_count #19580

pull troygiorshev wants to merge 1 commits into bitcoin:master from troygiorshev:2020-07-remove-message_count changing 1 files +8 −7
  1. troygiorshev commented at 12:17 PM on July 24, 2020: contributor

    Inspired by this comment on #18638.

    message_count is almost completely unused. Additionally, its values are not always consistent with last_message (i.e. we sometimes simultaneously have message_count['foo'] == 1 and 'foo' not in last_message).

    This PR removes it and replaces its only use with a new has_verack boolean.

  2. Remove message_count, replace with has_verack
    message_count is almost completely unused.  Additionally, the values it
    holds are no longer correct.
    
    This commit removes it and replaces its only use with a new has_verack
    boolean.
    daad490204
  3. fanquake added the label Tests on Jul 24, 2020
  4. MarcoFalke renamed this:
    Remove message_count
    test: Remove message_count
    on Jul 24, 2020
  5. laanwj commented at 1:43 PM on July 24, 2020: member

    I don't understand why the counts would not be correct, but agree has_verack as boolean is clerer.

  6. troygiorshev commented at 1:50 PM on July 24, 2020: contributor

    I don't understand why the counts would not be correct, but agree has_verack as boolean is clerer.

    In the tests in #18638, we do last_message.pop('ping'), after which we simultaneously have message_count['ping'] == 1 and 'ping' not in last_message.

    Thanks for the comment, I've edited the PR description to clarify what I mean by "wrong".

  7. jnewbery commented at 1:54 PM on July 24, 2020: member

    I don't think this is an improvement. It's making the P2PConnection class less generic by hard-coding specific message types into the base class.

    I also don't think that it's an issue that last_message['foo'] is empty and message_count['foo'] is > 0.

    EDIT: This is not a NACK. I don't see the benefit of removing this, but if other people do, I don't feel strongly that it needs to stay.

  8. promag commented at 10:37 PM on July 26, 2020: member

    Code review ACK daad49020427293506d88ae4d0242937232629c7.

    message_count was only ever used to track verack so has_verack (or verack_received as it was named in the past) is enough.

    It's making the P2PConnection class less generic by hard-coding specific message types into the base class. @jnewbery what do you mean? P2PConnection is not touched.

    I don't see the benefit of removing this, but if other people do, I don't feel strongly that it needs to stay.

    :+1:

  9. troygiorshev commented at 12:09 PM on July 27, 2020: contributor

    Closing this in favor of #19599

    I misunderstood the intended usage of message_count and last_message. Additionally, looking deeper at the code, the intended usage (almost completely) matches the actual usage. The comments just need to be cleaned up, which is done in the above PR.

    I now agree with:

    I also don't think that it's an issue that last_message['foo'] is empty and message_count['foo'] is > 0.

    If people are uncomfortable with unused code, this PR can be reopened but should use 2020-07-remove-message_count-v2 instead. It does away with has_verack.

  10. troygiorshev closed this on Jul 27, 2020

  11. MarcoFalke referenced this in commit 149eca433d on Jul 30, 2020
  12. sidhujag referenced this in commit 64a985d7fc on Jul 31, 2020
  13. PastaPastaPasta referenced this in commit ed7060338a on Sep 17, 2021
  14. PastaPastaPasta referenced this in commit 6d48f06071 on Sep 19, 2021
  15. thelazier referenced this in commit 14934edaaf on Sep 25, 2021
  16. DrahtBot locked this on Feb 15, 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-26 12:14 UTC

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