| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.NAT.Relay.Limit
Description
Client-side enforcement of a relay-advertised circuit budget.
specsrelaycircuit-v2: the relay counts bytes on the relayed
connection itself (the byte stream after the hop or stop handshake),
separately in each direction, and resets both sides when either
direction exceeds data or the circuit has been open for duration.
A component of 0, or an absent component, is unlimited. An omitted
limit means the relay applies none.
This wrapper charges that same stream. A write that does not fit is
not sent. A read never consumes a byte past the cap. Once either
budget is exhausted the underlying stream is closed and every later
read or write throws RelayCircuitExhausted, rather than waiting for
the relay's reset to surface as an opaque transport failure.
Documentation
data RelayCircuitExhausted Source #
Why a relayed circuit was closed locally.
Instances
| Exception RelayCircuitExhausted Source # | |
Defined in LibP2P.NAT.Relay.Limit | |
| Show RelayCircuitExhausted Source # | |
Defined in LibP2P.NAT.Relay.Limit Methods showsPrec :: Int -> RelayCircuitExhausted -> ShowS # show :: RelayCircuitExhausted -> String # showList :: [RelayCircuitExhausted] -> ShowS # | |
| Eq RelayCircuitExhausted Source # | |
Defined in LibP2P.NAT.Relay.Limit Methods (==) :: RelayCircuitExhausted -> RelayCircuitExhausted -> Bool # (/=) :: RelayCircuitExhausted -> RelayCircuitExhausted -> Bool # | |
toRelayCircuitLimit :: RelayLimit -> RelayCircuitLimit Source #
Copy a relay protobuf limit into the transport-level budget.
enforceRelayCircuitLimit :: Maybe RelayCircuitLimit -> StreamIO -> IO StreamIO Source #
Charge stream against mLimit. A missing or inactive budget
(every component 0 or absent) is returned unchanged. The duration
clock starts when this returns, which is when the hop or stop
handshake has completed and the stream has become the circuit.