Commit Graph

343 Commits

Author SHA1 Message Date
1e9e42065a weighted bucket: implement update_pending 2020-03-24 19:27:06 +03:00
0c724c815f weighted bucket: set weight to 0 in tests 2020-03-24 17:29:53 +03:00
8f5cc730b1 weighted bucket: it compiles! 2020-03-24 17:24:22 +03:00
7eb6d425a4 weighted bucket: cleanup WIP 2020-03-24 14:22:41 +03:00
5b098a6e72 weighted bucket: implement update 2020-03-24 13:38:44 +03:00
826fb99483 weighted bucket: implement apply_pending 2020-03-24 12:56:27 +03:00
d5c0112fbb weighted bucket: implement insert() 2020-03-24 12:08:39 +03:00
760e6baac3 bucket: cleanup 2020-03-20 20:11:17 +03:00
6ba164e6d9 bucket: revert pattern matching 2020-03-20 20:00:05 +03:00
fe0a141e0e bucket: cleanup 2020-03-20 19:45:04 +03:00
d8b42a5cb1 bucket: apply_pending works 2020-03-20 19:36:33 +03:00
c096db5e59 bucket: apply_pending WIP 2020-03-20 18:46:47 +03:00
0d66695d3b update works 2020-03-20 18:35:57 +03:00
2aa6fbc93f insert works 2020-03-20 18:11:19 +03:00
51b441247f cleanup 2020-03-19 18:38:37 +03:00
235d23dcaa Refactor duplicated code 2020-03-19 18:36:38 +03:00
9b93e500a7 arrrgh 2020-03-19 16:40:04 +03:00
1dc62e61f2 use trust-graph 2020-03-19 15:50:12 +03:00
87b8e23553 cleanup 2020-03-19 15:12:48 +03:00
84fc48f1ac Add public key to buckets 2020-03-19 14:52:59 +03:00
vms
e9240755f8 contact 2020-03-19 12:32:08 +03:00
619ed94e64 Add public key to buckets WIP 2020-03-19 12:11:04 +03:00
783ff2575e Add public key to buckets WIP 2020-03-18 18:16:36 +03:00
1b3a30aa6c Add public key to buckets WIP 2020-03-17 18:35:39 +03:00
e8bce909d0 Exchange public key WIP 2020-03-17 17:59:33 +03:00
eaae132be1 Exchange public key WIP 2020-03-17 15:26:33 +03:00
263c237070 Exchange public key WIP 2020-03-17 14:17:16 +03:00
9b52ca6d0f Exchange public key WIP 2020-03-17 14:02:16 +03:00
4f7d290b7a Exchange public key WIP 2020-03-17 13:24:01 +03:00
13c48c0f19 Exchange public key WIP 2020-03-16 21:00:06 +03:00
912b4d7021 Exchange public key WIP 2020-03-16 19:35:22 +03:00
3ed32a6a1b pass local key 2020-03-16 19:13:00 +03:00
0343c129a5 Add Contact 2020-03-16 18:39:05 +03:00
65bb4f2b7d Comment out tests for better IDE experience, add some comments 2020-03-16 16:54:53 +03:00
10089c5f46 Use upstream version of multihash instead of a fork (#1472)
The changes from the libp2p fork have been backported to upstream, hence
upstream can now be used instead.
2020-03-05 16:49:36 +01:00
8337687b3a Multiple connections per peer (#1440)
* Allow multiple connections per peer in libp2p-core.

Instead of trying to enforce a single connection per peer,
which involves quite a bit of additional complexity e.g.
to prioritise simultaneously opened connections and can
have other undesirable consequences [1], we now
make multiple connections per peer a feature.

The gist of these changes is as follows:

The concept of a "node" with an implicit 1-1 correspondence
to a connection has been replaced with the "first-class"
concept of a "connection". The code from `src/nodes` has moved
(with varying degrees of modification) to `src/connection`.
A `HandledNode` has become a `Connection`, a `NodeHandler` a
`ConnectionHandler`, the `CollectionStream` was the basis for
the new `connection::Pool`, and so forth.

Conceptually, a `Network` contains a `connection::Pool` which
in turn internally employs the `connection::Manager` for
handling the background `connection::manager::Task`s, one
per connection, as before. These are all considered implementation
details. On the public API, `Peer`s are managed as before through
the `Network`, except now the API has changed with the shift of focus
to (potentially multiple) connections per peer. The `NetworkEvent`s have
accordingly also undergone changes.

The Swarm APIs remain largely unchanged, except for the fact that
`inject_replaced` is no longer called. It may now practically happen
that multiple `ProtocolsHandler`s are associated with a single
`NetworkBehaviour`, one per connection. If implementations of
`NetworkBehaviour` rely somehow on communicating with exactly
one `ProtocolsHandler`, this may cause issues, but it is unlikely.

[1]: https://github.com/paritytech/substrate/issues/4272

* Fix intra-rustdoc links.

* Update core/src/connection/pool.rs

Co-Authored-By: Max Inden <mail@max-inden.de>

* Address some review feedback and fix doc links.

* Allow responses to be sent on the same connection.

* Remove unnecessary remainders of inject_replaced.

* Update swarm/src/behaviour.rs

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

* Update swarm/src/lib.rs

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

* Update core/src/connection/manager.rs

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

* Update core/src/connection/manager.rs

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

* Update core/src/connection/pool.rs

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

* Incorporate more review feedback.

* Move module declaration below imports.

* Update core/src/connection/manager.rs

Co-Authored-By: Toralf Wittner <tw@dtex.org>

* Update core/src/connection/manager.rs

Co-Authored-By: Toralf Wittner <tw@dtex.org>

* Simplify as per review.

* Fix rustoc link.

* Add try_notify_handler and simplify.

* Relocate DialingConnection and DialingAttempt.

For better visibility constraints.

* Small cleanup.

* Small cleanup. More robust EstablishedConnectionIter.

* Clarify semantics of `DialingPeer::connect`.

* Don't call inject_disconnected on InvalidPeerId.

To preserve the previous behavior and ensure calls to
`inject_disconnected` are always paired with calls to
`inject_connected`.

* Provide public ConnectionId constructor.

Mainly needed for testing purposes, e.g. in substrate.

* Move the established connection limit check to the right place.

* Clean up connection error handling.

Separate connection errors into those occuring during
connection setup or upon rejecting a newly established
connection (the `PendingConnectionError`) and those
errors occurring on previously established connections,
i.e. for which a `ConnectionEstablished` event has
been emitted by the connection pool earlier.

* Revert change in log level and clarify an invariant.

* Remove inject_replaced entirely.

* Allow notifying all connection handlers.

Thereby simplify by introducing a new enum `NotifyHandler`,
used with a single constructor `NetworkBehaviourAction::NotifyHandler`.

* Finishing touches.

Small API simplifications and code deduplication.
Some more useful debug logging.

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Toralf Wittner <tw@dtex.org>
2020-03-04 13:49:25 +01:00
7cbb3cf8f3 Add Mdns::discovered_nodes (#1480) 2020-03-02 17:11:28 +01:00
2c40f2880e Publish 0.16.2 (#1476) 2020-02-28 10:54:52 +01:00
62ea7c165b Upgrade crypto libs (#1470) 2020-02-26 13:23:52 +01:00
2ea459dcdc kad: Export QueryId and add Kademlia::protocol_name. (#1469)
The `QueryId` type should be exported as it is used in the
`NetworkBehaviour::ProtocolsHandler` type of `Kademlia`.

`Kademlia::protocol_name` is added for convenience.
2020-02-25 11:59:38 +01:00
vms
688aa5bc79 Move mdns (#1458)
* move mdns

* alphabetic ordering in Cargo.toml

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-24 19:36:55 +01:00
fa4cd50476 Publish 0.16.1 (#1459) 2020-02-18 14:05:22 +01:00
b6a93b3c5e Small libp2p-kad tweaks. (#1457)
* Replace some remaining `AsRef` constraints for DHT keys with `Borrow`.
  * Add a bit of debug/trace logging.
  * Tiny refactoring and a debug assertion for the `bucket` module.
2020-02-17 14:52:11 +01:00
57cab3b7ce secio: Use UnexpectedEof instead of BrokenPipe. (#1456)
Secio's handshake reports unexpected EOF errors in two places.
Presumably because `std::io::ErrorKind::UnexpectedEof` did not exist
when secio was first implemented, `ErrorKind::BrokenPipe` is used
for this error. Since we nowadays have `UnexpectedEof` at our disposal,
secio should use this more appropriate error kind.
2020-02-14 14:46:13 +01:00
be31f66031 Revert bumping multistream-select and bump multihash (#1455)
* Revert bumping multistream-select

* Also bump multihash
2020-02-14 13:33:28 +01:00
ace8123cf2 Publish 0.16.0 (#1453)
* Publish 0.16.0

* Apply suggestions from code review

Co-Authored-By: Toralf Wittner <tw@dtex.org>

Co-authored-by: Toralf Wittner <tw@dtex.org>
2020-02-14 11:33:52 +01:00
70d634daff Grow noise buffers dynamically. (#1436)
* Grow noise buffers dynamically.

Currently we allocate a buffer of 176 KiB for each noise state, i.e.
each connection. For connections which see only small data frames
this is wasteful. At the same time we limit the max. write buffer size
to 16 KiB to keep the total buffer size relatively small, which
results in smaller encrypted messages and also makes it less likely to
ever encounter the max. noise package size of 64 KiB in practice when
communicating with other nodes using the same implementation.

This PR repaces the static buffer allocation with a dynamic one. We
only reserve a small space for the authentication tag plus some extra
reserve and are able to buffer larger data frames before encrypting.

* Grow write buffer from offset.

As suggested by @mxinden, this prevents increasing the write buffer up
to MAX_WRITE_BUF_LEN.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 12:38:33 +01:00
bbed28b3ec Make errors on listener non-fatal (#1427)
* Make errors on listener non-fatal

* Fix bad rename

* Some changes to trait bounds

* Fix noise tests

* Apply suggestions from code review

Co-Authored-By: Toralf Wittner <tw@dtex.org>

* Add reason for closure

* Fix intra-doc link

Co-authored-by: Toralf Wittner <tw@dtex.org>
2020-02-13 12:05:45 +01:00
b872bd9030 Temporary canonical multihash in peer ID. (#1449)
* Temporary canonical multihash in peer ID.

* Reduce code duplication.

* Remove unnecessary impls.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-13 10:36:14 +01:00
8238fd2100 Switch noise from the RingResolver to the DefaultResolver (#1439)
* hmm...

* Switch snow resolver to default

* Fix documentation

* Use the sha2 crate for sha512 hashing

* Use ring on native

* Use different features on different targets

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-02-12 21:44:50 +01:00