Skip to content

Commit

Permalink
Add two caches to the peers state machine (#2898)
Browse files Browse the repository at this point in the history
The `Peers` state machine has two functions:
`unfulfilled_desired_outbound_substreams` and
`fulfilled_undesired_outbound_substreams`. They return a list of
peer-substreams tuples.

These two functions are called very frequently (every time something
happens on the networking), they are `O(n)` (they iterate over every
single substream of every single peer), and most of the time they return
nothing.

This PR adds two new fields to the `peers` state machine with the same
names as these functions.
The functions now simply return the content of the field, and the field
is updated pro-actively whenever something else changes.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
tomaka and mergify[bot] authored Oct 19, 2022
1 parent b7d13d7 commit c6fa161
Showing 1 changed file with 251 additions and 58 deletions.
Loading

0 comments on commit c6fa161

Please sign in to comment.