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

Fix flaws in the API of peers.rs #2610

Merged
merged 10 commits into from
Aug 11, 2022
Merged

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Aug 11, 2022

Close #2370

This PR removes weirdnesses in the implementation of peers.rs by improving its API. There is now a StartShutdown event similar to collection.rs, after which it is invalid to start requests. After this event has been generated, all open substreams will be closed.

See #2369 for more context.

I think I've preserved the same behavior in service.rs as before this PR, but I'm not completely sure of that. One exception is that we now properly clean up k-buckets when a connection was still handshaking is shut down.
I will improve service.rs as a follow-up to this PR.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 11, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────
       -4491 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::next_event::h666cfc906727b7e9
       +4313 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::next_event::h7668105a2b015c60
       -3636 ┊ smoldot::libp2p::collection::Network<TConn,TNow>::next_event::hd3decd1b94c9165f
       +3607 ┊ smoldot::libp2p::collection::Network<TConn,TNow>::next_event::hcbcf200208b538da
       +1071 ┊ hashbrown::raw::RawTable<T,A>::reserve_rehash::hecdda9ec2788a2a6
        -974 ┊ hashbrown::raw::RawTable<T,A>::reserve_rehash::h8853276c0fe71d92
        +877 ┊ smoldot::libp2p::collection::Network<TConn,TNow>::new::hc44c39a7ff318bac
        -877 ┊ smoldot::libp2p::collection::Network<TConn,TNow>::new::he7ccf4c8bb989fd3
        -767 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::new::h0321a30cb2d79fa0
        +761 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::unfulfilled_desired_peers::h8b26c0dcc0dcf53f
        -761 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::unfulfilled_desired_peers::hc03d905eb3e219cb
        +599 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::new::h032b5cd57b39b6c2
        +585 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::set_peer_notifications_out_desired::h492018cea696be50
        -585 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::set_peer_notifications_out_desired::h9e962a98fcaf6513
        +504 ┊ <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::h46d014401c5ba2ac
        -504 ┊ <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::h927616064ec0d40c
        +495 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::try_clean_up_peer::h5d0a36ebe7ac7d13
        -495 ┊ smoldot::libp2p::peers::Peers<TConn,TNow>::try_clean_up_peer::h75d4244451d0d17d
        -438 ┊ smoldot::libp2p::collection::Network<TConn,TNow>::insert_single_stream::heee6ce585e5638cf
        -435 ┊ <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::h15c902de2910dc7d
       -2520 ┊ ... and 304 more.
       -5734 ┊ Σ [324 Total Rows]

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Aug 11, 2022
@mergify mergify bot merged commit c41f2df into paritytech:main Aug 11, 2022
@tomaka tomaka deleted the peers-api-fix branch August 11, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding a "shutting down" phase in the API of peers.rs
1 participant