7 Commits

Author SHA1 Message Date
Divma
2066a192ad
protocols/gossipsub: Add mesh metrics (#2316)
Enable instrumenting mesh through metrics and add gossipsub to
misc/metrics.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-16 14:59:39 +01:00
Max Inden
06c339c141
protocols/kad: Refactor KademliaEvent (#2321)
Rename `KademliaEvent::InboundRequestServed` to `KademliaEvent::InboundRequest` and move
`InboundPutRecordRequest` into `InboundRequest::PutRecord` and `InboundAddProviderRequest` into
`InboundRequest::AddProvider`.

Co-authored-by: supercmmetry <vishaals2000@gmail.com>
2021-10-30 15:50:45 +02:00
Max Inden
40c5335e3b
core/: Concurrent dial attempts (#2248)
Concurrently dial address candidates within a single dial attempt.

Main motivation for this feature is to increase success rate on hole punching
(see https://github.com/libp2p/rust-libp2p/issues/1896#issuecomment-885894496
for details). Though, as a nice side effect, as one would expect, it does
improve connection establishment time.

Cleanups and fixes done along the way:

- Merge `pool.rs` and `manager.rs`.

- Instead of manually implementing state machines in `task.rs` use
  `async/await`.

- Fix bug where `NetworkBehaviour::inject_connection_closed` is called without a
  previous `NetworkBehaviour::inject_connection_established` (see
  https://github.com/libp2p/rust-libp2p/issues/2242).

- Return handler to behaviour on incoming connection limit error. Missed in
  https://github.com/libp2p/rust-libp2p/issues/2242.
2021-10-14 18:05:07 +02:00
Max Inden
fcb2f62752
misc/metrics/src/swarm: Expose role on connections_closed (#2220)
Expose whether closed connection was a Dialer or Listener.
2021-09-09 15:35:45 +02:00
Max Inden
9b1f405012
misc/metrics/src/kad: Set query_duration lowest bucket to 0.1 sec (#2219)
Probability for a Kademlia query to return in less than 100 milliseconds
is low, thus increasing the lower bucket to improve accuracy within the
higher ranges.
2021-09-08 18:44:03 +02:00
Max Inden
c161acfb50
*: Dial with handler and return handler on error and closed (#2191)
Require `NetworkBehaviourAction::{DialPeer,DialAddress}` to contain a
`ProtocolsHandler`. This allows a behaviour to attach custom state to its
handler. The behaviour would no longer need to track this state separately
during connection establishment, thus reducing state required in a behaviour.
E.g. in the case of `libp2p-kad` the behaviour can include a `GetRecord` request
in its handler, or e.g. in the case of `libp2p-request-response` the behaviour
can include the first request in the handler.

Return `ProtocolsHandler` on connection error and close. This allows a behaviour
to extract its custom state previously included in the handler on connection
failure and connection closing. E.g. in the case of `libp2p-kad` the behaviour
could extract the attached `GetRecord` from the handler of the failed connection
and then start another connection attempt with a new handler with the same
`GetRecord` or bubble up an error to the user.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-08-31 17:00:51 +02:00
Max Inden
98bc5e6486
misc/metrics: Add auxiliary crate to record events as OpenMetrics (#2063)
This commit adds an auxiliary crate recording protocol and Swarm events
and exposing them as metrics in the OpenMetrics format.
2021-08-13 22:51:54 +02:00