Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExchangeHandler stats fix #1205

Merged
merged 3 commits into from Aug 23, 2018
Merged

ExchangeHandler stats fix #1205

merged 3 commits into from Aug 23, 2018

Conversation

carver
Copy link
Contributor

@carver carver commented Aug 21, 2018

What was wrong?

Trying to call get_stats() on the exchange handler was crashing. Broken during #1184

How was it fixed?

Keep a link to all the exchange managers, and use them to call get stats.

Cute Animal Picture

put a cute animal picture link inside the parentheses

@pipermerriam
Copy link
Member

Any chance I can twist your arm into writing up 1-2 basic smoke tests for this? Should be structurally similar to how the tests/trinity/core/p2p-proto/test_peer_block_header_validator_api.py tests are written.

@carver
Copy link
Contributor Author

carver commented Aug 22, 2018

Sure, fair enough. Almost any bug fix that wasn't caught by CI should add a new test.

By structurally similar, I assume you mean that the test should send a request and then validate that the stats are updated?

also, a bugfix for getting stats before any requests are made
@pipermerriam
Copy link
Member

By structurally similar, I assume you mean that the test should send a request and then validate that the stats are updated?

Yes


for attr, exchange_cls in self._exchanges.items():
if hasattr(self, attr):
raise AttributeError(
"Unable to set manager on attribute `{0}` which is already "
"present on the class: {1}".format(attr, getattr(self, attr))
)
manager: ExchangeManager[Any, Any, Any] = ExchangeManager(self._peer, peer.cancel_token)
manager: ExchangeManager[Any, Any, Any]
manager = ExchangeManager(self._peer, exchange_cls.response_cmd_type, peer.cancel_token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the classproperty is being used to reduce the length of this lookup from exchance_cls.request_class.reponse_cmd_type to exchange_cls.response_cmd_type.

I'm not convinced that the classproperty decorator is worth this given that it required us to silence mypy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of the mypy silencer, so I kept the class property thing.

@carver carver merged commit 14aec04 into ethereum:master Aug 23, 2018
@carver carver deleted the exchange-patch branch August 23, 2018 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants