Crate kad
Available on crate feature
kad
only.Expand description
Implementation of the libp2p-specific Kademlia protocol.
§Important Discrepancies
- Peer Discovery with Identify In other libp2p implementations, the
Identify protocol might be seen as a core protocol. Rust-libp2p
tries to stay as generic as possible, and does not make this assumption.
This means that the Identify protocol must be manually hooked up to Kademlia through calls
to
Behaviour::add_address
. If you choose not to use the Identify protocol, and do not provide an alternative peer discovery mechanism, a Kademlia node will not discover nodes beyond the network’s boot nodes. Without the Identify protocol, existing nodes in the kademlia network cannot obtain the listen addresses of nodes querying them, and thus will not be able to add them to their routing table.
Modules§
Structs§
- AddProvider
Ok - The successful result of publishing a provider record.
- Addresses
- A non-empty list of (unique) addresses of a peer in the routing table. Every address must be a fully-qualified /p2p address.
- Behaviour
Behaviour
is aNetworkBehaviour
that implements the libp2p Kademlia protocol.- Bootstrap
Ok - The successful result of
Behaviour::bootstrap
. - Config
- The configuration for the
Kademlia
behaviour. - Entry
View - A cloned, immutable view of an entry that is either present in a bucket or pending insertion.
- GetClosest
Peers Ok - The successful result of
Behaviour::get_closest_peers
. - KBucket
Distance - A distance between two keys in the DHT keyspace.
- KBucket
Key - A
Key
in the DHT keyspace with preserved preimage. - KBucket
Ref - A reference to a bucket.
- KadPeer
- Information about a peer, as known by the sender.
- NoKnown
Peers - An operation failed to due no known peers in the routing table.
- Peer
Info - Peer Info combines a Peer ID with a set of multiaddrs that the peer is listening on.
- Peer
Record - A record either received by the given peer or retrieved from the local record store.
- Progress
Step - Information about progress events.
- Provider
Record - A record stored in the DHT whose value is the ID of a peer who can provide the value on-demand.
- PutRecord
Ok - The successful result of
Behaviour::put_record
. - QueryId
- Unique identifier for an active query.
- Query
Mut - A mutable reference to a running query.
- Query
Ref - An immutable reference to a running query.
- Query
Stats - Execution statistics of a query.
- Record
- A record stored in the DHT.
- Record
Key - The (opaque) key of a record.
- U256
- Little-endian large integer type 256-bit unsigned integer.
Enums§
- AddProvider
Context - The context of a
QueryInfo::AddProvider
query. - AddProvider
Error - The possible errors when publishing a provider record.
- AddProvider
Phase - The phases of a
QueryInfo::AddProvider
query. - Bootstrap
Error - The error result of
Behaviour::bootstrap
. - Bucket
Inserts - The configurable strategies for the insertion of peers and their addresses into the k-buckets of the Kademlia routing table.
- Caching
- The configuration for Kademlia “write-back” caching after successful
lookups via
Behaviour::get_record
. - Connection
Type - Status of our connection to a node reported by the Kademlia protocol.
- Event
- The events produced by the
Kademlia
behaviour. - GetClosest
Peers Error - The error result of
Behaviour::get_closest_peers
. - GetProviders
Error - The error result of
Behaviour::get_providers
. - GetProviders
Ok - The successful result of
Behaviour::get_providers
. - GetRecord
Error - The error result of
Behaviour::get_record
. - GetRecord
Ok - The successful result of
Behaviour::get_record
. - Inbound
Request - Information about a received and handled inbound request.
- Mode
- Node
Status - The status of a node in a bucket.
- PutRecord
Context - The context of a
QueryInfo::PutRecord
query. - PutRecord
Error - The error result of
Behaviour::put_record
. - PutRecord
Phase - The phases of a
QueryInfo::PutRecord
query. - Query
Info - Information about a running query.
- Query
Result - The results of Kademlia queries.
- Quorum
- A quorum w.r.t. the configured replication factor specifies the minimum number of distinct nodes that must be successfully contacted in order for a query to succeed.
- Routing
Update - The possible outcomes of
Behaviour::add_address
. - Store
Inserts - The configurable filtering strategies for the acceptance of incoming records.
Constants§
- ALPHA_
VALUE - The
α
parameter of the Kademlia specification. - K_VALUE
- The
k
parameter of the Kademlia specification. - PROTOCOL_
NAME
Type Aliases§
- AddProvider
Result - The result of publishing a provider record.
- Bootstrap
Result - The result of
Behaviour::bootstrap
. - GetClosest
Peers Result - The result of
Behaviour::get_closest_peers
. - GetProviders
Result - The result of
Behaviour::get_providers
. - GetRecord
Result - The result of
Behaviour::get_record
. - PutRecord
Result - The result of
Behaviour::put_record
.