| 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, and findProviders. These compose the lower-level
iterative lookups (iterativeFindNode, iterativeGetProviders) with
direct RPC sending to the closest peers found.
Synopsis
- provide :: DHTNode -> [Multiaddr] -> ByteString -> IO ()
- putValue :: DHTNode -> Validator -> ByteString -> ByteString -> IO (Either String ())
- findProviders :: DHTNode -> ByteString -> IO [ProviderEntry]
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.
findProviders :: DHTNode -> ByteString -> IO [ProviderEntry] Source #
Find providers for a content key.
Convenience wrapper around iterativeGetProviders.