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

refactor(gossipsub)!: initialize ProtocolConfig from GossipsubConfig #3381

Merged
merged 5 commits into from
Jan 26, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

This simplifies the tests as we don't have to go through the new_handler abstraction.

Notes

Extracted out of #3254.
Unfortunately, this is a breaking change because the protocol module is public. See #3303 (comment) for more discussion.

Links to any relevant issues

Open Questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Other than the changelog entry, good to merge from my end.

Comment on lines +9 to +12
- Initialize `ProtocolConfig` via `GossipsubConfig`. See [PR 3381].

[PR 3207]: https://github.com/libp2p/rust-libp2p/pull/3207/
[PR 3381]: https://github.com/libp2p/rust-libp2p/pull/3381/
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need a changelog entry? This is not user facing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is (unfortunately) part of the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to remove it again if you think that doesn't warrant an entry!

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I am surprised. No strong opinion. Let's keep as is 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it's something I'd like to fix. See linked discussion in PR description.

@mxinden
Copy link
Member

mxinden commented Jan 26, 2023

Clippy stable is continuously failing with:

 error[E0061]: this function takes 1 argument but 5 arguments were supplied
Error:    --> protocols/gossipsub/src/behaviour/tests.rs:275:17
    |
275 |                 ProtocolConfig::new(Cow::from(""), None, 0, ValidationMode::None, false),
    |                 ^^^^^^^^^^^^^^^^^^^                ----  -  --------------------  ----- argument of type `bool` unexpected
    |                                                    |     |  |
    |                                                    |     |  argument of type `config::ValidationMode` unexpected
    |                                                    |     argument of type `{integer}` unexpected
    |                                                    argument of type `std::option::Option<_>` unexpected
    |
note: expected `&config::GossipsubConfig`, found enum `std::borrow::Cow`
   --> protocols/gossipsub/src/behaviour/tests.rs:275:37
    |
275 |                 ProtocolConfig::new(Cow::from(""), None, 0, ValidationMode::None, false),
    |                                     ^^^^^^^^^^^^^
    = note: expected reference `&config::GossipsubConfig`
                    found enum `std::borrow::Cow<'_, str>`
note: associated function defined here
   --> protocols/gossipsub/src/protocol.rs:60:12
    |
60  |     pub fn new(gossipsub_config: &GossipsubConfig) -> ProtocolConfig {
    |            ^^^ ----------------------------------
help: remove the extra arguments
    |
275 |                 ProtocolConfig::new(/* &config::GossipsubConfig */),
    |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0061`.
error: could not compile `libp2p-gossipsub` due to previous error

@mergify mergify bot merged commit e552022 into master Jan 26, 2023
@mergify mergify bot deleted the 2824-refactor-gossipsub-protocolconfig branch January 26, 2023 14:39
@thomaseizinger
Copy link
Contributor Author

Thanks for fixing this, must have been a bad merge or something!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants