Skip to content

test: Remove message_count - #19580

Closed
troygiorshev wants to merge 1 commit into
bitcoin:masterfrom
troygiorshev:2020-07-remove-message_count
Closed

troygiorshev wants to merge 1 commit into
bitcoin:masterfrom
troygiorshev:2020-07-remove-message_count

Conversation

@troygiorshev

@troygiorshev troygiorshev commented Jul 24, 2020 •

Copy link
Copy Markdown
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.

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.
@fanquake fanquake added the Tests label Jul 24, 2020
@maflcko maflcko changed the title Remove message_count test: Remove message_count Jul 24, 2020
@laanwj

laanwj commented Jul 24, 2020

Copy link
Copy Markdown
Member

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

@troygiorshev

Copy link
Copy Markdown
Contributor Author

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".

@jnewbery

jnewbery commented Jul 24, 2020 •

Copy link
Copy Markdown
Contributor

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.

@promag

promag commented Jul 26, 2020 •

Copy link
Copy Markdown
Contributor

Code review ACK daad490.

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.

👍

@troygiorshev

troygiorshev commented Jul 27, 2020 •

Copy link
Copy Markdown
Contributor Author

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.

maflcko pushed a commit that referenced this pull request Jul 30, 2020
2c6a02e Clean message_count and last_message (Troy Giorshev)

Pull request description:

  From #19580

  This PR changes comments to clarify the intended usage of `message_count` and `last_message`.  Additionally it changes the only usage of `message_count` to use `last_message` instead, bringing the code into alignment with the intended usage.

  Note: Now `message_count` is completely unused.  However, it is ready to be used (i.e. the supporting code works) and likely will be used in some test in the future.

ACKs for top commit:
  jnewbery:
    utACK 2c6a02e

Tree-SHA512: 07c7684c9586de4f845e10d7aac36c1aab9fb56b409949c1c70d5ca705bc3971ca7d5943245a0472def4efd7b4e1c5dad2f713db5ead8fca08404daf4891e98b
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 19, 2021
2c6a02e Clean message_count and last_message (Troy Giorshev)

Pull request description:

  From bitcoin#19580

  This PR changes comments to clarify the intended usage of `message_count` and `last_message`.  Additionally it changes the only usage of `message_count` to use `last_message` instead, bringing the code into alignment with the intended usage.

  Note: Now `message_count` is completely unused.  However, it is ready to be used (i.e. the supporting code works) and likely will be used in some test in the future.

ACKs for top commit:
  jnewbery:
    utACK 2c6a02e

Tree-SHA512: 07c7684c9586de4f845e10d7aac36c1aab9fb56b409949c1c70d5ca705bc3971ca7d5943245a0472def4efd7b4e1c5dad2f713db5ead8fca08404daf4891e98b
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants