| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.DHT.API
Contents
Description
High-level DHT API for content publishing and retrieval.
Provides the user-facing operations that libp2p applications use:
provide, putValue, getValue, findProviders, and findPeer.
These compose the lower-level iterative lookups with direct RPC sending
to the closest peers found.
Synopsis
- provide :: DHTNode -> [Multiaddr] -> ByteString -> IO ()
- putValue :: DHTNode -> Validator -> ByteString -> ByteString -> IO (Either String ())
- getValue :: DHTNode -> Validator -> ByteString -> IO (Either String DHTRecord)
- findProviders :: DHTNode -> ByteString -> IO [ProviderEntry]
- findPeer :: DHTNode -> PeerId -> IO [BucketEntry]
Content provider operations
provide :: DHTNode -> [Multiaddr] -> ByteString -> IO () Source #
Announce that the local node provides a given content key.
Performs an iterative FIND_NODE lookup for the content key, then sends ADD_PROVIDER messages to the k closest peers found. The local peer's listen addresses are included so remote peers can dial back.
putValue :: DHTNode -> Validator -> ByteString -> ByteString -> IO (Either String ()) Source #
Store a value in the DHT under the given key.
Performs an iterative FIND_NODE lookup for the key, then sends
PUT_VALUE messages to the k closest peers. Also stores the value
locally. The value is validated using the node's configured validator;
if validation fails, the function returns Left with an error message.
getValue :: DHTNode -> Validator -> ByteString -> IO (Either String DHTRecord) Source #
Retrieve a value from the DHT.
Convenience wrapper around iterativeGetValue.
findProviders :: DHTNode -> ByteString -> IO [ProviderEntry] Source #
Find providers for a content key.
Convenience wrapper around iterativeGetProviders.
findPeer :: DHTNode -> PeerId -> IO [BucketEntry] Source #
Find the closest known peers to a target peer ID.
Convenience wrapper around iterativeFindNode.