module LibP2P.Transport
( ConnectionEndpoint (..)
, NativeMuxer (..)
, RawConnection (..)
, Listener (..)
, Transport (..)
) where
import LibP2P.Crypto.PeerId (PeerId)
import LibP2P.Multiaddr (Multiaddr)
import LibP2P.MultistreamSelect.Negotiation (ProtocolId, StreamIO)
data NativeMuxer = NativeMuxer
{ NativeMuxer -> PeerId
nativePeerId :: !PeerId
, NativeMuxer -> ProtocolId
nativeSecurity :: !ProtocolId
, NativeMuxer -> ProtocolId
nativeMuxerProtocol :: !ProtocolId
, NativeMuxer -> IO StreamIO
nativeOpenStream :: !(IO StreamIO)
, NativeMuxer -> IO StreamIO
nativeAcceptStream :: !(IO StreamIO)
, NativeMuxer -> IO ()
nativeClose :: !(IO ())
}
data ConnectionEndpoint
= ByteStreamEndpoint !StreamIO
| NativeMuxerEndpoint !NativeMuxer
data RawConnection = RawConnection
{ RawConnection -> ConnectionEndpoint
rcEndpoint :: !ConnectionEndpoint
, RawConnection -> Multiaddr
rcLocalAddr :: !Multiaddr
, RawConnection -> Multiaddr
rcRemoteAddr :: !Multiaddr
, RawConnection -> IO ()
rcClose :: !(IO ())
}
data Listener = Listener
{ Listener -> IO RawConnection
listenerAccept :: !(IO RawConnection)
, Listener -> IO ()
listenerClose :: !(IO ())
, Listener -> Multiaddr
listenerAddr :: !Multiaddr
}
data Transport = Transport
{ Transport -> Multiaddr -> IO RawConnection
transportDial :: !(Multiaddr -> IO RawConnection)
, Transport -> Maybe Multiaddr -> Multiaddr -> IO RawConnection
transportDialFrom :: !(Maybe Multiaddr -> Multiaddr -> IO RawConnection)
, Transport -> Multiaddr -> IO Listener
transportListen :: !(Multiaddr -> IO Listener)
, Transport -> Multiaddr -> Bool
transportCanDial :: !(Multiaddr -> Bool)
}