| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.DHT.Maintenance
Description
DHT provider republishing and value-record expiry maintenance.
Synopsis
- data DHTMaintenanceConfig = DHTMaintenanceConfig {}
- defaultDHTMaintenanceConfig :: DHTMaintenanceConfig
- data DHTMaintenanceState
- newDHTMaintenanceState :: DHTMaintenanceConfig -> IO DHTMaintenanceState
- startValueGCWorker :: DHTMaintenanceState -> TVar Bool -> TVar (Map ByteString DHTRecord) -> IO ()
- runValueGCTick :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> IO ()
- ensureProviderWorker :: DHTMaintenanceState -> TVar Bool -> IO Int -> IO ()
- stopDHTMaintenance :: DHTMaintenanceState -> IO ()
- storeReceivedRecord :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> DHTRecord -> IO ()
- lookupLiveRecord :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> ByteString -> IO (Maybe DHTRecord)
- recordIsExpired :: DHTMaintenanceState -> UTCTime -> DHTRecord -> Bool
- rememberLocalProvider :: DHTMaintenanceState -> ByteString -> [Multiaddr] -> IO ()
- nextLocalProviderBatch :: DHTMaintenanceState -> IO [(ByteString, [Multiaddr])]
Documentation
data DHTMaintenanceConfig Source #
Scheduling, expiry, and per-tick work limits for DHT maintenance.
Constructors
| DHTMaintenanceConfig | |
Fields
| |
defaultDHTMaintenanceConfig :: DHTMaintenanceConfig Source #
go-libp2p Amino DHT defaults: providers republish every 22 hours, value records expire after 48 hours, and value GC runs every 24 hours.
data DHTMaintenanceState Source #
Mutable worker state owned by one DHT node.
startValueGCWorker :: DHTMaintenanceState -> TVar Bool -> TVar (Map ByteString DHTRecord) -> IO () Source #
Start the bounded value-record GC loop. Non-positive age or interval disables the worker, matching go-libp2p's configuration semantics.
runValueGCTick :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> IO () Source #
Delete at most one configured batch of expired records.
ensureProviderWorker :: DHTMaintenanceState -> TVar Bool -> IO Int -> IO () Source #
Start the provider worker once. After each configured interval it walks every locally provided key in bounded batches, yielding between batches.
stopDHTMaintenance :: DHTMaintenanceState -> IO () Source #
Cancel every maintenance worker and clear their handles.
storeReceivedRecord :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> DHTRecord -> IO () Source #
Store a value record with a receiver-controlled timestamp.
lookupLiveRecord :: DHTMaintenanceState -> TVar (Map ByteString DHTRecord) -> ByteString -> IO (Maybe DHTRecord) Source #
Read a live record, deleting malformed, misfiled, or expired data.
recordIsExpired :: DHTMaintenanceState -> UTCTime -> DHTRecord -> Bool Source #
Whether a record is older than the configured maximum age. Missing or malformed receive times are expired when age checking is enabled.
rememberLocalProvider :: DHTMaintenanceState -> ByteString -> [Multiaddr] -> IO () Source #
Track a key that this node still provides.
nextLocalProviderBatch :: DHTMaintenanceState -> IO [(ByteString, [Multiaddr])] Source #
Select the next bounded provider batch, rotating through the keyspace so a large provider set cannot starve keys beyond the first batch.