* Adapt examples to async style loop
* Adapt async style loop for chat.rs
* Adapt async style loop for distributed-key-value-store.rs
* Adapt async style loop for gossibsub-chat.rs
* Adapt async style loop for ipfs-private.rs
* Adapt ping to use async
* Update tutorial crate to reflect new changes
Co-authored-by: Max Inden <mail@max-inden.de>
Enable advanced dialing requests both on `Swarm` and via
`NetworkBehaviourAction`. Users can now trigger a dial with a specific
set of addresses, optionally extended via
`NetworkBehaviour::addresses_of_peer`. In addition the whole process is
now modelled in a type safe way via the builder pattern.
Example of a `NetworkBehaviour` requesting a dial to a specific peer
with a set of addresses additionally extended through
`NetworkBehaviour::addresses_of_peer`:
```rust
NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(PeerCondition::Always)
.addresses(addresses)
.extend_addresses_through_behaviour()
.build(),
handler,
}
```
Example of a user requesting a dial to an unknown peer with a single
address via `Swarm`:
```rust
swarm1.dial(
DialOpts::unknown_peer_id()
.address(addr2.clone())
.build()
)
```
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.
Basic file sharing application with peers either providing or locating
and getting files by name.
While obviously showcasing how to build a basic file sharing
application, the actual goal of this example is **to show how to
integrate rust-libp2p into a larger application**.
Architectural properties
- Clean clonable async/await interface ([`Client`]) to interact with the
network layer.
- Single task driving the network layer, no locks required.
Don't close connection if ping protocol is unsupported by remote. Previously, a
failed protocol negotation for ping caused a force close of the connection. As a
result, all nodes in a network had to support ping. To allow networks where some
nodes don't support ping, we now emit `PingFailure::Unsupported` once for every
connection on which ping is not supported.
Co-authored-by: Max Inden <mail@max-inden.de>
Change `Stream` implementation of `ExpandedSwarm` to return all
`SwarmEvents` instead of only the `NetworkBehaviour`'s events.
Remove `ExpandedSwarm::next_event`. Users can use `<ExpandedSwarm as
StreamExt>::next` instead.
Remove `ExpandedSwarm::next`. Users can use `<ExpandedSwarm as
StreamExt>::filter_map` instead.
This commit extends the ping example in `src/tutorial.rs, by walking a
newcomer through the implementation of a simple ping node step-by-step,
introducing all the core libp2p concepts along the way.
With the ping tutorial in place, there is no need for the lengthy libp2p
crate level introduction, which is thus removed with this commit.
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Remove `Deref` and `DerefMut` implementations previously dereferencing
to the `NetworkBehaviour` on `Swarm`. Instead one can access the
`NetworkBehaviour` via `Swarm::behaviour` and `Swarm::behaviour_mut`.
Methods on `Swarm` can now be accessed directly, e.g. via
`my_swarm.local_peer_id()`.
Reasoning: Accessing the `NetworkBehaviour` of a `Swarm` through `Deref`
and `DerefMut` instead of a method call is an unnecessary complication,
especially for newcomers. In addition, `Swarm` is not a smart-pointer
and should thus not make use of `Deref` and `DerefMut`, see documentation
from the standard library below.
> Deref should only be implemented for smart pointers to avoid
confusion.
https://doc.rust-lang.org/std/ops/trait.Deref.html
* Implement /ipfs/id/push/1.0.0 alongside some refactoring.
* Implement /ipfs/id/push/1.0.0, i.e. the ability to actively
push information of the local peer to specific remotes.
* Make the initial delay as well as the recurring delay
for the periodic identification requests configurable,
introducing `IdentifyConfig`.
* Fix test.
* Fix example.
* Update protocols/identify/src/identify.rs
Co-authored-by: Max Inden <mail@max-inden.de>
* Update protocols/identify/src/identify.rs
Co-authored-by: Max Inden <mail@max-inden.de>
* Update versions and changelogs.
Co-authored-by: Max Inden <mail@max-inden.de>
* Implement `/dnsaddr` support on `libp2p-dns`.
To that end, since resolving `/dnsaddr` addresses needs
"fully qualified" multiaddresses when dialing, i.e. those
that end with the `/p2p/...` protocol, we make sure that
dialing always uses such fully qualified addresses by
appending the `/p2p` protocol as necessary. As a side-effect,
this adds support for dialing peers via "fully qualified"
addresses, as an alternative to using a `PeerId` together
with a `Multiaddr` with or without the `/p2p` protocol.
* Adapt libp2p-relay.
* Update versions, changelogs and small cleanups.
* [libp2p-dns] Use trust-dns-resolver.
Use the `trust-dns-resolver` library for DNS resolution,
thereby removing current use of the thread pool.
Since `trust-dns-resolver` and related crates already
provide support for both `async-std` and `tokio`, we
make use of that here in our own feature flags.
Since `trust-dns-resolver` provides many useful
configuration options and error detail, central
types of `trust-dns-resolver` like `ResolverConfig`,
`ResolverOpts` and `ResolveError` are re-exposed
in the API of `libp2p-dns`. Full encapsulation
does not seem preferable in this case.
* Cleanup
* Fix two intra-doc links.
* Simplify slightly.
* Incorporate review feedback.
* Remove git dependency and fix example.
* Update version and changelogs.
* Update tomls.
* Let transports decide when to translate.
* Improve tcp transport.
* Update stuff.
* Remove background task. Enhance documentation.
To avoid spawning a background task and thread within
`TcpConfig::new()`, with communication via unbounded channels,
a `TcpConfig` now keeps track of the listening addresses
for port reuse in an `Arc<RwLock>`. Furthermore, an `IfWatcher`
is only used by a `TcpListenStream` if it listens on any interface
and directly polls the `IfWatcher` both for initialisation and
new events.
Includes some documentation and test enhancements.
* Reintroduce feature flags for tokio vs async-io.
To avoid having an extra reactor thread running for tokio
users and to make sure all TCP I/O uses the mio-based
tokio reactor.
Thereby run tests with both backends.
* Add missing files.
* Fix docsrs attributes.
* Update transports/tcp/src/lib.rs
Co-authored-by: Max Inden <mail@max-inden.de>
* Restore chat-tokio example.
* Forward poll_write_vectored for tokio's AsyncWrite.
* Update changelogs.
Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Max Inden <mail@max-inden.de>
This commit upgrades the current gossipsub implementation to support the [v1.1
spec](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md).
It adds a number of features, bug fixes and performance improvements.
Besides support for all new 1.1 features, other improvements that are of particular note:
- Improved duplicate LRU-time cache (this was previously a severe bottleneck for
large message throughput topics)
- Extended message validation configuration options
- Arbitrary topics (users can now implement their own hashing schemes)
- Improved message validation handling - Invalid messages are no longer dropped
but sent to the behaviour for application-level processing (including scoring)
- Support for floodsub, gossipsub v1 and gossipsub v2
- Protobuf encoding has been shifted into the behaviour. This has permitted two
improvements:
1. Message size verification during publishing (report to the user if the
message is too large before attempting to send).
2. Message fragmentation. If an RPC is too large it is fragmented into its
sub components and sent in smaller chunks.
Additional Notes
The peer eXchange protocol defined in the v1.1 spec is inactive in its current
form. The current implementation permits sending `PeerId` in `PRUNE` messages,
however a `PeerId` is not sufficient to form a new connection to a peer. A
`Signed Address Record` is required to safely transmit peer identity
information. Once these are confirmed (https://github.com/libp2p/specs/pull/217)
a future PR will implement these and make PX usable.
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Rüdiger Klaehn <rklaehn@protonmail.com>
Co-authored-by: blacktemplar <blacktemplar@a1.net>
Co-authored-by: Rüdiger Klaehn <rklaehn@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roman S. Borschel <roman@parity.io>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Co-authored-by: David Craven <david@craven.ch>
* Streamline mplex and yamux configurations.
* For all configuration options that exist for both multiplexers
and have the same semantics, use the same names for the
configuration.
* Rename `Config` to `YamuxConfig` for consistentcy with
the majority of other protocols, e.g. `MplexConfig`, `PingConfig`,
`KademliaConfig`, etc.
* Completely hide `yamux` APIs within `libp2p-yamux`. This allows
to fully control the libp2p API and streamline it with other
muxer APIs, consciously choosing e.g. which configuration options
to make configurable in libp2p and which to fix to certain values.
It does also not necessarily prescribe new incompatible version bumps of
yamux for `libp2p-yamux`, as no `yamux` types are exposed. The cost
is some more duplication of configuration options in the API, as well
as the need to update `libp2p-yamux` if `yamux` introduces new
configuration options that `libp2p-yamux` wants to expose as well.
* Update CHANGELOGs.
* add tokio floodsub chat example
* use swarmbuilder to specify tokio executor
* fix comments
* Tweak tokio chat example.
Co-authored-by: Roman S. Borschel <roman@parity.io>
This adds optional message signing and verification to the gossipsub protocol as
per the libp2p specifications.
In addition this commit:
- Removes the LruCache received cache and simply uses the memcache in it's
place.
- Send subscriptions to all peers
- Prevent invalid messages from being gossiped
- Send grafts when subscriptions are added to the mesh
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Rüdiger Klaehn <rklaehn@protonmail.com>
Co-authored-by: Rüdiger Klaehn <rklaehn@gmail.com>
The extension paper S-Kademlia includes a proposal for lookups over
disjoint paths. Within vanilla Kademlia, queries keep track of the
closest nodes in a single bucket. Any adversary along the path can thus
influence all future paths, in case they can come up with the
next-closest (not overall closest) hops. S-Kademlia tries to solve the
attack above by querying over disjoint paths using multiple buckets.
To adjust the libp2p Kademlia implementation accordingly this change-set
introduces an additional peers iterator: `ClosestDisjointPeersIter`.
This new iterator wraps around a set of `ClosestPeersIter`
`ClosestDisjointPeersIter` enforces that each of the `ClosestPeersIter`
explore disjoint paths by having each peer instantly return that was
queried by a different iterator before.
* [libp2p-kad] Provide more insight and control into Kademlia queries.
More insight: The API allows iterating over the active queries and
inspecting their state and execution statistics.
More control: The API allows aborting queries prematurely
at any time.
To that end, API operations that initiate new queries return the query ID
and multi-phase queries such as `put_record` retain the query ID across all
phases, each phase being executed by a new (internal) query.
* Cleanup
* Cleanup
* Update examples and re-exports.
* Incorporate review feedback.
* Update CHANGELOG
* Update CHANGELOG
Co-authored-by: Max Inden <mail@max-inden.de>
* Add gossipsub and ping
* Implement swarm key parsing from environment
* WIP remove stuff
* WIP remove more stuff
* Use gossipsub instead of floodsub
* Make ipfs example work with or without swarm key
* Add support for /ipfs/Qm1234 multiaddrs
* Add documentation for ipfs example
* Rename example to ipfs-private
* Fix comments
* Move EitherTransport into either.rs
And prettify imports of ipfs-private example
* Sanitize multiaddr before parsing
...and remove the "ipfs" protocol from multiaddr
* Remove TSubstream type parameter
...so that it works with current master
* PR feedback
use source instead of cause
* Simplify trait bounds requirements
* More work
* Moar
* Finish
* Fix final tests
* More simplification
* Use separate traits for Inbound/Outbound
* Update gossipsub and remove warnings
* Add documentation to swarm
* Remove BoxSubstream
* Fix tests not compiling
* Fix stack overflow
* Address concerns
* For some reason my IDE ignored libp2p-kad
* Addressing #473 ... if I understood the ticket right, we want to pass through whatever the application provides as a topic identifier, leaving hashing (or not hashing) up to the application.
* Remove TopicDescriptor and use Topic newtype everywhere
* PR feedback
Use From<Topic> instead of Into<String>
Use impl Into<Topic> instead of Topic in public API
Co-authored-by: Peat Bakke <peat@peat.org>
* Create gossipsub crate - Basic template, borrowed from floodsub
* Add a GossipsubConfig struct and set up basic structures in the Gossipsub struct
* Begin implementation of join. Adds get_random_peers helper function and adds tests
* Implements gossipsub leave()
* Update publishMany to incorporate gossipsub mesh and fanout logic
* Use the gossipsub mesh for determining peer subscription
* Remove subscribed_topics field from the Gossipsub struct
* Rename gossipsubconfig to ProtocolConfig
* Implement the gossipsub control messages into the Codec's Encode/Decode and modifies GossipsubRpc
* Modify GossipsubActions to enums for succinctness.
* Modify the memcache to store Gossipsub messages
* Implement control message handling.
* Update control message handling to handle multiple messages.
* Handle received gossipsub messages using pre-built handlers.
* Remove excess connected peer hashmap
* Add extra peer mapping and consistent topic naming.
* Implement heartbeat, emit_gossip and send_graft_prune.
* Group logic in forwarding messages. Add messages to memcache.
* Add heartbeat timer and move location of helper function.
* Add gossipsub the libp2p workspace, makes layer structs public
* Add logging to gossipsub
- Adds the log crate and implements logging macros
- Specifies versions for external crates
* Add example chat for debugging purposes
* Implement #868 for gossipsub.
* Add rust documentation to gossipsub crate.
- Adds basic documentation, overview and examples to the gossipsub
crate.
* Re-introduce the initial heartbeat time config.
This commit also adds the inject_connected test.
* Add subscribe tests.
- Modifies `handle_received_subscriptions` to take a reference of
subscriptions
- Adds `test_subscribe`
- Adds `test_handle_received_subscriptions`
- Adds tests for the filter in `get_random_peers`
* Add Bug fixes and further testing for gossipsub.
- Corrects the tuple use of topic_hashes
- Corrects JOIN logic around fanout and adding peers to the mesh
- Adds test_unsubscribe
- Adds test_join
* Rename GossipsubMessage::msg_id -> id
* Add bug fix for handling disconnected peers.
* Implements (partially) #889 for Gossipsub.
* handle_iwant event count tests
* handle_ihave event count tests
* Move layer.rs tests into separate file.
* Implement clippy suggestions for gossipsub.
* Modify control message tests for specific types.
* Implement builder pattern for GossipsubConfig.
As suggested by @twittner - The builder pattern for building
GossipsubConfig struct is implemented.
* Package version updates as suggested by @twittner.
* Correct line lengths in gossipsub.
* Correct braces in found by @twittner.
* Implement @twittner's suggestions.
- Uses `HashSet` where applicable
- Update `FnvHashMap` to standard `HashMap`
- Uses `min` function in code simplification.
* Add NodeList struct to clarify topic_peers.
* Cleaner handling of messagelist
Co-Authored-By: AgeManning <Age@AgeManning.com>
* Cleaner handling of added peers.
Co-Authored-By: AgeManning <Age@AgeManning.com>
* handle_prune peer removed test
* basic grafting tests
* multiple topic grafting test
* Convert &vec to slice.
Co-Authored-By: AgeManning <Age@AgeManning.com>
* Convert to lazy insert.
Co-Authored-By: AgeManning <Age@AgeManning.com>
* Cleaner topic handling.
Co-Authored-By: AgeManning <Age@AgeManning.com>
* control pool piggybacking
using HashMap.drain() in control_pool_flush
going to squash this
* Add Debug derives to gossipsub and correct tests.
* changes from PR
squash this
all tests passing, but still some that need to be reconsidered
test reform
* Implements Arc for GossipsubRpc events
* Remove support for floodsub nodes
* Reconnected to disconnected peers, to mitigate timeout
* Use ReadOne WriteOne with configurable max gossip sizes
* Remove length delimination from RPC encoding
* Prevent peer duplication in mesh
* Allow oneshot handler's inactivity_timeout to be configurable
* Correct peer duplication in mesh bug
* Remove auto-reconnect to allow for user-level disconnects
* Single long-lived inbound/outbound streams to match go implementation
* Allow gossipsub topics to be optionally hashable
* Improves gossipsub stream handling
- Corrects the handler's keep alive.
- Correct the chat example.
- Instantly add peers to the mesh on subscription if the mesh is low.
* Allows message validation in gossipsub
* Replaces Cuckoofilter with LRUCache
The false positive rate was unacceptable for rejecting messages.
* Renames configuration parameter and corrects logic
* Removes peer from fanout on disconnection
* Add publish and fanout tests
* Apply @mxinden suggestions
* Resend message if outbound stream negotiated
- Downgrades log warnings
* Implement further reviewer suggestions
- Created associated functions to avoid unnecessary cloning
- Messages are rejected if their sequence numbers are not u64
- `GossipsbuConfigBuilder` has the same defaults as `GossipsubConfig`
- Miscellaneous typos
* Add MessageId type and remove unnecessary comments
* Add a return value to propagate_message function
* Adds user-customised gossipsub message ids
* Adds the message id to GossipsubEvent
* Implement Debug for GossipsubConfig
* protocols/gossipsub: Add basic smoke test
Implement a basic smoke test that:
1. Builds a fully connected graph of size N.
2. Subscribes each node to the same topic.
3. Publishes a single message.
4. Waits for all nodes to receive the above message.
N and the structure of the graph are reproducibly randomized via
Quickcheck.
* Corrections pointed out by @mxinden
* Add option to remove source id publishing
* protocols/gossipsub/tests/smoke: Remove unused variable
* Merge latest master
* protocols/gossipsub: Move to stable futures
* examples/gossipsub-chat.rs: Move to stable futures
* protocols/gossipsub/src/behaviour/tests: Update to stable futures
* protocols/gossipsub/tests: Update to stable futures
* protocols/gossipsub: Log substream errors
* protocols/gossipsub: Log outbound substream errors
* Remove rust-fmt formatting
* Shift to prost for protobuf compiling
* Use wasm_timer for wasm compatibility
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Toralf Wittner <tw@dtex.org>
Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
* misc/mdns: Make MdnsService::new sync by using std::net::UdpSocket::bind
MdnsService uses an IP address to create a UDP socket. The address does
not need to be resolved. Therefore one can use std's UdpSocket::bind
instead of the async counterpart from async-std. As a result
MdnsService::new and MdnsService::silent don't need to be async.
* examples/mdns-passive-discovery: Don't await sync MdnsService::new
* misc/mdns/src/behaviour: Make Mdns::new sync
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
* add docs about deriving NetworkBehaviour
* add commentary to the chat example
also minor stuff like reordering to match the struct elements, note why the listening address is
reported in poll.
* fix remove the warning on the example ignored field
* Apply suggestions from code review
Thanks for suggestions!
Co-Authored-By: Max Inden <mail@max-inden.de>
* chore cleanup added docs after suggestions
* fix print all listening addresses in examples/chat
not that there should be more than one but it makes sense to repeat the full example here.
* chore remove confusing writing on printing the listening addrs
* fix use intra-docs, spelling
Co-Authored-By: Roman S. Borschel <roman@parity.io>
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
* Configurable multistream-select protocol. Add V1Lazy variant. (#1245)
Make the multistream-select protocol (version) configurable
on transport upgrades as well as for individual substreams.
Add a "lazy" variant of multistream-select 1.0 that delays
sending of negotiation protocol frames as much as possible
but is only safe to use under additional assumptions that
go beyond what is required by the multistream-select v1
specification.
* Improve the code readability of the chat example (#1253)
* Add bridged chats (#1252)
* Try fix CI (#1261)
* Print Rust version on CI
* Don't print where not appropriate
* Change caching strategy
* Remove win32 build
* Remove win32 from list
* Update libsecp256k1 dep to 0.3.0 (#1258)
* Update libsecp256k1 dep to 0.3.0
* Sign now cannot fail
* Upgrade url and percent-encoding deps to 2.1.0 (#1267)
* Upgrade percent-encoding dep to 2.1.0
* Upgrade url dep to 2.1.0
* Revert CIPHERS set to null (#1273)
* Update dependency versions (#1265)
* Update versions of many dependencies
* Bump version of rand
* Updates for changed APIs in rand, ring, and webpki
* Replace references to `snow::Session`
`Session` no longer exists in `snow` but the replacement is two structs `HandshakeState` and `TransportState`
Something will have to be done to harmonize `NoiseOutput.session`
* Add precise type for UnparsedPublicKey
* Update data structures/functions to match new snow's API
* Delete diff.diff
Remove accidentally committed diff file
* Remove commented lines in identity/rsa.rs
* Bump libsecp256k1 to 0.3.1
* Implement /plaintext/2.0.0 (#1236)
* WIP
* plaintext/2.0.0
* Refactor protobuf related issues to compatible with the spec
* Rename: new PlainTextConfig -> PlainText2Config
* Keep plaintext/1.0.0 as PlainText1Config
* Config contains pubkey
* Rename: proposition -> exchange
* Add PeerId to Exchange
* Check the validity of the remote's `Exchange`
* Tweak
* Delete unused import
* Add debug log
* Delete unused field: public_key_encoded
* Delete unused field: local
* Delete unused field: exchange_bytes
* The inner instance should not be public
* identity::Publickey::Rsa is not available on wasm
* Delete PeerId from Config as it should be generated from the pubkey
* Catch up for #1240
* Tweak
* Update protocols/plaintext/src/error.rs
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
* Update protocols/plaintext/src/handshake.rs
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
* Update protocols/plaintext/src/error.rs
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
* Update protocols/plaintext/src/error.rs
Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>
* Update protocols/plaintext/src/error.rs
Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>
* Rename: pubkey -> local_public_key
* Delete unused error
* Rename: PeerIdValidationFailed -> InvalidPeerId
* Fix: HandShake -> Handshake
* Use bytes insteadof Publickey to avoid code duplication
* Replace with ProtobufError
* Merge HandshakeContext<()> into HandshakeContext<Local>
* Improve the peer ID validation to simplify the handshake
* Propagate Remote to allow extracting the PeerId from the Remote
* Collapse the same kind of errors into the variant
* [noise]: `sodiumoxide 0.2.5` (#1276)
Fixes https://github.com/RustSec/advisory-db/pull/192
* examples/ipfs-kad.rs: Remove outdated reference to `without_init` (#1280)
* CircleCI Test Fix (#1282)
* Disabling "Docker Layer Caching" because it breaks one of the circleci checks
* Bump to trigger CircleCI build
* unbump
* zeroize: Upgrade to v1.0 (#1284)
v1.0 final release is out. Release notes:
https://github.com/iqlusioninc/crates/pull/279
* *: Consolidate protobuf scripts and update to rust-protobuf 2.8.1 (#1275)
* *: Consolidate protobuf generation scripts
* *: Update to rust-protobuf 2.8.1
* *: Mark protobuf generated modules with '_proto'
* examples: Add distributed key value store (#1281)
* examples: Add distributed key value store
This commit adds a basic distributed key value store supporting GET and
PUT commands using Kademlia and mDNS.
* examples/distributed-key-value-store: Fix typo
* Simple Warning Cleanup (#1278)
* Cleaning up warnings - removing unused `use`
* Cleaning up warnings - unused tuple value
* Cleaning up warnings - removing dead code
* Cleaning up warnings - fixing deprecated name
* Cleaning up warnings - removing dead code
* Revert "Cleaning up warnings - removing dead code"
This reverts commit f18a765e4bf240b0ed9294ec3ae5dab5c186b801.
* Enable the std feature of ring (#1289)
* Configurable multistream-select protocol. Add V1Lazy variant. (#1245)
Make the multistream-select protocol (version) configurable
on transport upgrades as well as for individual substreams.
Add a "lazy" variant of multistream-select 1.0 that delays
sending of negotiation protocol frames as much as possible
but is only safe to use under additional assumptions that
go beyond what is required by the multistream-select v1
specification.
* Improve the code readability of the chat example (#1253)
* Add bridged chats (#1252)
* Try fix CI (#1261)
* Print Rust version on CI
* Don't print where not appropriate
* Change caching strategy
* Remove win32 build
* Remove win32 from list
* Update libsecp256k1 dep to 0.3.0 (#1258)
* Update libsecp256k1 dep to 0.3.0
* Sign now cannot fail
* Upgrade url and percent-encoding deps to 2.1.0 (#1267)
* Upgrade percent-encoding dep to 2.1.0
* Upgrade url dep to 2.1.0
* Fix more conflicts
* Revert CIPHERS set to null (#1273)
* Somewhat complete the implementation of Kademlia records.
This commit relates to [libp2p-146] and [libp2p-1089].
* All records expire (by default, configurable).
* Provider records are also stored in the RecordStore, and the RecordStore
API extended.
* Background jobs for periodic (re-)replication and (re-)publication
of records. Regular (value-)records are subject to re-replication and
re-publication as per standard Kademlia. Provider records are only
subject to re-publication.
* For standard Kademlia value lookups (quorum = 1), the record is cached
at the closest peer to the key that did not return the value, as per
standard Kademlia.
* Expiration times of regular (value-)records is computed exponentially
inversely proportional to the number of nodes between the local node
and the closest node known to the key (beyond the k closest), as per
standard Kademlia.
The protobuf messages are extended with two fields: `ttl` and `publisher`
in order to implement the different semantics of re-replication (by any
of the k closest peers to the key, not affecting expiry) and re-publication
(by the original publisher, resetting the expiry). This is not done yet in
other libp2p Kademlia implementations, see e.g. [libp2p-go-323]. The new protobuf fields
have been given somewhat unique identifiers to prevent future collision.
Similarly, periodic re-publication of provider records does not seem to
be done yet in other implementations, see e.g. [libp2p-js-98].
[libp2p-146]: https://github.com/libp2p/rust-libp2p/issues/146
[libp2p-1089]: https://github.com/libp2p/rust-libp2p/issues/1089
[libp2p-go-323]: https://github.com/libp2p/go-libp2p-kad-dht/issues/323
[libp2p-js-98]: https://github.com/libp2p/js-libp2p-kad-dht/issues/98
* Tweak kad-ipfs example.
* Add missing files.
* Ensure new delays are polled immediately.
To ensure task notification, since `NotReady` is returned right after.
* Fix ipfs-kad example and use wasm_timer.
* Small cleanup.
* Incorporate some feedback.
* Adjustments after rebase.
* Distinguish events further.
In order for a user to easily distinguish the result of e.g.
a `put_record` operation from the result of a later republication,
different event constructors are used. Furthermore, for now,
re-replication and "caching" of records (at the closest peer to
the key that did not return a value during a successful lookup)
do not yield events for now as they are less interesting.
* Speed up tests for CI.
* Small refinements and more documentation.
* Guard a node against overriding records for which it considers
itself to be the publisher.
* Document the jobs module more extensively.
* More inline docs around removal of "unreachable" addresses.
* Remove wildcard re-exports.
* Use NonZeroUsize for the constants.
* Re-add method lost on merge.
* Add missing 'pub'.
* Further increase the timeout in the ipfs-kad example.
* Readd log dependency to libp2p-kad.
* Simplify RecordStore API slightly.
* Some more commentary.
* Change Addresses::remove to return Result<(),()>.
Change the semantics of `Addresses::remove` so that the error case
is unambiguous, instead of the success case. Use the `Result` for
clearer semantics to that effect.
* Add some documentation to .
The example typically runs into a lot of connection timeouts,
which may cause the query to time out. A query timeout currently
results in the example to be considered failed, but the example
should only be considered failed if no closest peers are found,
whether the query timed out or not.
* Address some TODOs, refactor queries and public API.
The following left-over issues are addressed:
* The key for FIND_NODE requests is generalised to any Multihash,
instead of just peer IDs.
* All queries get a (configurable) timeout.
* Finishing queries as soon as enough results have been received is simplified
to avoid code duplication.
* No more panics in provider-API-related code paths. The provider API is
however still untested and (I think) still incomplete (e.g. expiration
of provider records).
* Numerous smaller TODOs encountered in the code.
The following public API changes / additions are made:
* Introduce a `KademliaConfig` with new configuration options for
the replication factor and query timeouts.
* Rename `find_node` to `get_closest_peers`.
* Rename `get_value` to `get_record` and `put_value` to `put_record`,
introducing a `Quorum` parameter for both functions, replacing the
existing `num_results` parameter with clearer semantics.
* Rename `add_providing` to `start_providing` and `remove_providing`
to `stop_providing`.
* Add a `bootstrap` function that implements a (almost) standard
Kademlia bootstrapping procedure.
* Rename `KademliaOut` to `KademliaEvent` with an updated list of
constructors (some renaming). All events that report query results
now report a `Result` to uniformly permit reporting of errors.
The following refactorings are made:
* Introduce some constants.
* Consolidate `query.rs` and `write.rs` behind a common query interface
to reduce duplication and facilitate better code reuse, introducing
the notion of a query peer iterator. `query/peers/closest.rs`
contains the code that was formerly in `query.rs`. `query/peers/fixed.rs` contains
a modified variant of `write.rs` (which is removed). The new `query.rs`
provides an interface for working with a collection of queries, taking
over some code from `behaviour.rs`.
* Reduce code duplication in tests and use the current_thread runtime for
polling swarms to avoid spurious errors in the test output due to aborted
connections when a test finishes prematurely (e.g. because a quorum of
results has been collected).
* Some additions / improvements to the existing tests.
* Fix test.
* Fix rebase.
* Tweak kad-ipfs example.
* Incorporate some feedback.
* Provide easy access and conversion to keys in error results.