22 Commits

Author SHA1 Message Date
Pierre Krieger
089e349671
Pass the ConnectedPoint to into_handler() (#1085) 2019-05-10 11:05:22 +02:00
Toralf Wittner
fd0e48bf37 Add IntoProtocolsHandler::inbound_protocol. (#1099) 2019-05-08 20:23:28 +02:00
Pierre Krieger
ce4ca3cc75
Switch to wasm-timer (#1071) 2019-04-25 15:08:06 +02:00
Roman Borschel
8cde987e6d Rename KeepAlive constructors. (#1078)
* KeepAlive::Now => KeepAlive::No
  * KeepAlive::Forever => KeepAlive::Yes

As suggested in #1072.
2019-04-23 11:58:49 +02:00
Roman Borschel
45f308c815
Small addendum to #1072. (#1077)
* Small addendum to #1072.

  * Missed two review comments related to documentation.
  * Avoid creating new `Delay`s when possible, i.e. when the deadline
    did not change, since they're not exactly cheap and returning
    `KeepAlive::Until(t)` with the same instant `t` over a prolonged
    period of time is common.

* Even better.
2019-04-21 15:48:50 +02:00
Roman Borschel
d5c6370b15
Remove libp2p-ping keep-alive functionality. (#1067)
* Fix connection & handler shutdown when using `KeepAlive::Now`.

Delay::new(Instant::now()) is never immediately ready, resulting in
`KeepAlive::Now` to have no effect, since the delay is re-created on
every execution of `poll()` in the `NodeHandlerWrapper`. It can also
send the node handler into a busy-loop, since every newly
created Delay will trigger a task wakeup, which creates a new Delay
with Instant::now(), and so forth.

The use of `Delay::new(Instant::now())` for "immediate" connection shutdown
is therefore removed here entirely. An important assumption is thereby
that as long as the node handler non-empty `negotiating_in` and `negotiating_out`,
the handler is not dependent on such a Delay for task wakeup.

* Correction to the libp2p-ping connection timeout.

The current connection timeout is always short of one `interval`,
because the "countdown" begins with the last received or sent pong
(depending on the policy). In effect, the current default config has
a connection timeout of 5 seconds (20 - 15) from the point when a ping is sent.

Instead, the "countdown" of the connection timeout should always begin
with the next scheduled ping. That also makes all configurations valid,
avoiding pitfalls.

The important properties of the ping handler are now checked to hold for all
configurations, in particular:

  * The next ping must be scheduled no earlier than the ping interval
    and no later than the connection timeout.

  * The "countdown" for the connection timeout starts on the next ping,
    i.e. the full connection timeout remains at the instant when the
    next ping is sent.

* Do not keep connections alive.

The ping protocol is not supposed to keep otherwise idle connections
alive, only to add an additional condition for terminating them in
the form of a configurable number of consecutive failed ping requests.

In this context, the `PingPolicy` does not seem useful any longer.
2019-04-20 16:16:31 +02:00
Roman Borschel
bee5c58b27
libp2p-ping improvements. (#1049)
* libp2p-ping improvements.

  * re #950: Removes use of the `OneShotHandler`, but still sending each
    ping over a new substream, as seems to be intentional since #828.

  * re #842: Adds an integration test that exercises the ping behaviour through
    a Swarm, requiring the RTT to be below a threshold. This requires disabling
    Nagle's algorithm as it can interact badly with delayed ACKs (and has been
    observed to do so in the context of the new ping example and integration test).

  * re #864: Control of the inbound and outbound (sub)stream protocol upgrade
    timeouts has been moved from the `NodeHandlerWrapperBuilder` to the
    `ProtocolsHandler`. That may also alleviate the need for a custom timeout
    on an `OutboundSubstreamRequest` as a `ProtocolsHandler` is now free to
    adjust these timeouts over time.

Other changes:

  * A new ping example.
  * Documentation improvements.

* More documentation improvements.

* Add PingPolicy and ensure no event is dropped.

* Remove inbound_timeout/outbound_timeout.

As per review comment, the inbound timeout is now configured
as part of the `listen_protocol` and the outbound timeout as
part of the `OutboundSubstreamRequest`.

* Simplify and generalise.

Generalise `ListenProtocol` to `SubstreamProtocol`, reusing it in
the context of `ProtocolsHandlerEvent::OutboundSubstreamRequest`.

* Doc comments for SubstreamProtocol.

* Adapt to changes in master.

* Relax upper bound for ping integration test rtt.

For "slow" CI build machines?
2019-04-16 15:57:29 +02:00
Toralf Wittner
fac1ba12ec
Remove ProtocolsHandlerUpgrErr::MuxerDeniedSubstream. (#1043)
Closes #1042.
2019-04-04 19:11:59 +02:00
Pierre Krieger
ebbe197d9c
Remove remnants of shutdown process (#1020) 2019-03-28 15:36:26 -03:00
Pierre Krieger
8059a693a3
Cleaner shutdown process (#992)
* Cleaner shutdown process

* Finish

* Fix Yamux panic

* Remove irrelevant tests

* Update core/src/nodes/handled_node_tasks.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>

* Fix yamux error handling

* Update yamux
2019-03-11 17:19:50 +01:00
roignpar
f112f198b6 Add Ord implementation for KeepAlive (#918)
* Add Ord implementation for KeepAlive

* Fix import path

* Implement PartialOrd for KeepAlive

* remove Ord implementation

* Reimplement Ord for KeepAlive

* Add equality cases to KeepAlive Ord implementation
2019-02-14 11:35:24 +01:00
Roman Borschel
eeed66707b Address edition-2018 idioms. (#929) 2019-02-11 14:58:15 +01:00
Pierre Krieger
663ec7e8da
connection_keep_alive() now returns KeepAlive (#899)
* connection_keep_alive() now returns Option<Instant>

* Use KeepAlive instead of Option<Instant>
2019-01-30 16:37:34 +01:00
Pierre Krieger
35ec7f053c
Proper shutdown in ProtocolsHandlerSelect (#870)
* Proper shutdown in ProtocolsHandlerSelect

* Fix infinite loop
2019-01-29 19:52:22 +01:00
Pierre Krieger
a2ab7ff4a9
Simplify the floodsub handler (#868) 2019-01-22 14:45:03 +01:00
Pierre Krieger
bf52e9bd19
Add IntoNodeHandler and IntoProtocolsHandler traits (#848)
* Add IntoNodeHandler

* Add IntoProtocolsHandler
2019-01-14 14:22:25 +01:00
Pierre Krieger
5742a0000e
Add documentation to the core (#820) 2019-01-07 11:39:08 +01:00
Pierre Krieger
7da1a860be
Automatically close useless connections (#816)
* Automatically close useless connections

* Add a timeout before dropping the connection

* Rework the timeout

* Use OR to combine the outcome
2019-01-04 12:02:39 +01:00
Pierre Krieger
2c2fc8bfd3
Don't allow handlers::poll() to return None (#811) 2019-01-02 14:22:23 +01:00
Pierre Krieger
7798e23e78
Add an error associated type to ProtocolsHandler (#795) 2018-12-28 15:11:35 +01:00
Pierre Krieger
83320e0347
More precise error passed to inject_dial_upgrade_error (#771)
* More precise error passed to inject_dial_upgrade_error

* Fix concerns

* Fix panic proof
2018-12-18 11:23:13 +01:00
Pierre Krieger
dc55b00730
Split the protocols_handler.rs module into multiple submodules (#680)
* Rename protocols_handler.rs to protocols_handler/mod.rs

* Move DummyProtocolsHandler out of the module

* Extract ProtocolsHandlerSelect

* Extract NodeHandlerWrapper
2018-11-26 14:01:08 +01:00