Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Ouroboros-based implementation of Network
interface.
This implements a dumb FireForget
protocol and maintains one connection to each peer.
Contrary to other protocols implemented in Ouroboros, this is a push-based protocol.
Synopsis
- withIOManager :: WithIOManager
- data PortNumber
- newtype Network m msg = Network {
- broadcast :: msg -> m ()
- data Host = Host {
- hostname :: Text
- port :: PortNumber
- newtype NetworkCallback msg m = NetworkCallback {
- deliver :: msg -> m ()
- type NetworkComponent m inbound outbound a = NetworkCallback inbound m -> (Network m outbound -> m a) -> m a
- data TraceOuroborosNetwork msg
- = TraceSubscriptions (WithIPList (SubscriptionTrace SockAddr))
- | TraceErrorPolicy (WithAddr SockAddr ErrorPolicyTrace)
- | TraceAcceptPolicy AcceptConnectionsPolicyTrace
- | TraceHandshake (WithMuxBearer (ConnectionId SockAddr) (TraceSendRecv (Handshake HydraVersionedProtocolNumber Term)))
- | TraceSendRecv (TraceSendRecv (FireForget msg))
- data WithHost trace = WithHost Host trace
- data NetworkServerListenException = NetworkServerListenException {}
- tagged :: Text -> [Pair] -> Value
- withOuroborosNetwork :: forall inbound outbound. (ToCBOR outbound, FromCBOR outbound) => (ToCBOR inbound, FromCBOR inbound) => Tracer IO (WithHost (TraceOuroborosNetwork outbound)) -> HydraNetworkConfig -> (HydraHandshakeRefused -> IO ()) -> NetworkComponent IO inbound outbound ()
- encodeWithIPList :: WithIPList (SubscriptionTrace SockAddr) -> Value
- encodeWithAddr :: WithAddr SockAddr ErrorPolicyTrace -> Value
- encodeTraceSendRecvHandshake :: WithMuxBearer (ConnectionId SockAddr) (TraceSendRecv (Handshake HydraVersionedProtocolNumber Term)) -> [Pair]
- encodeTraceSendRecvFireForget :: forall msg. ToJSON msg => TraceSendRecv (FireForget msg) -> [Pair]
- data HydraNetworkConfig = HydraNetworkConfig {}
- data HydraVersionedProtocolData = MkHydraVersionedProtocolData
- hydraVersionedProtocolCodec :: CodecCBORTerm (String, Maybe Int) HydraVersionedProtocolNumber
- hydraVersionedProtocolDataCodec :: VersionDataCodec Term HydraVersionedProtocolNumber HydraVersionedProtocolData
Documentation
withIOManager :: WithIOManager #
data PortNumber #
Instances
newtype Network m msg Source #
Interface from the application to the network layer.
Host | |
|
Instances
Arbitrary Host Source # | |
FromJSON Host Source # | |
Defined in Hydra.Network | |
ToJSON Host Source # | |
Defined in Hydra.Network | |
Generic Host Source # | |
Read Host Source # | |
Show Host Source # | |
FromCBOR Host Source # | |
ToCBOR Host Source # | |
Defined in Hydra.Network encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy Host -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Host] -> Size | |
Eq Host Source # | |
Ord Host Source # | |
type Rep Host Source # | |
Defined in Hydra.Network type Rep Host = D1 ('MetaData "Host" "Hydra.Network" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "Host" 'PrefixI 'True) (S1 ('MetaSel ('Just "hostname") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "port") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PortNumber))) |
newtype NetworkCallback msg m Source #
Interface from network layer to the application. XXX: Reliably delivering a message in the crash-recovery fault model is tricky. According to "Introduction to Reliable and Secure Distributed Programming" section "2.2.4 Crashes with recoveries" explains that storing to stable storage and just pointing to stored events is a better way.
NetworkCallback | |
|
type NetworkComponent m inbound outbound a = NetworkCallback inbound m -> (Network m outbound -> m a) -> m a Source #
A type tying both inbound and outbound messages sending in a single Component.
A NetworkComponent
can have different inbound and outbound message types.
data TraceOuroborosNetwork msg Source #
TraceSubscriptions (WithIPList (SubscriptionTrace SockAddr)) | |
TraceErrorPolicy (WithAddr SockAddr ErrorPolicyTrace) | |
TraceAcceptPolicy AcceptConnectionsPolicyTrace | |
TraceHandshake (WithMuxBearer (ConnectionId SockAddr) (TraceSendRecv (Handshake HydraVersionedProtocolNumber Term))) | |
TraceSendRecv (TraceSendRecv (FireForget msg)) |
Instances
ToJSON msg => ToJSON (TraceOuroborosNetwork msg) Source # | |
Defined in Hydra.Network.Ouroboros toJSON :: TraceOuroborosNetwork msg -> Value toEncoding :: TraceOuroborosNetwork msg -> Encoding toJSONList :: [TraceOuroborosNetwork msg] -> Value toEncodingList :: [TraceOuroborosNetwork msg] -> Encoding omitField :: TraceOuroborosNetwork msg -> Bool |
Instances
FromJSON trace => FromJSON (WithHost trace) Source # | |
Defined in Hydra.Network.Ouroboros parseJSON :: Value -> Parser (WithHost trace) parseJSONList :: Value -> Parser [WithHost trace] omittedField :: Maybe (WithHost trace) | |
ToJSON trace => ToJSON (WithHost trace) Source # | |
Defined in Hydra.Network.Ouroboros toJSON :: WithHost trace -> Value toEncoding :: WithHost trace -> Encoding toJSONList :: [WithHost trace] -> Value toEncodingList :: [WithHost trace] -> Encoding | |
Show trace => Show (WithHost trace) Source # | |
data NetworkServerListenException Source #
Instances
withOuroborosNetwork :: forall inbound outbound. (ToCBOR outbound, FromCBOR outbound) => (ToCBOR inbound, FromCBOR inbound) => Tracer IO (WithHost (TraceOuroborosNetwork outbound)) -> HydraNetworkConfig -> (HydraHandshakeRefused -> IO ()) -> NetworkComponent IO inbound outbound () Source #
encodeWithIPList :: WithIPList (SubscriptionTrace SockAddr) -> Value Source #
encodeWithAddr :: WithAddr SockAddr ErrorPolicyTrace -> Value Source #
encodeTraceSendRecvHandshake :: WithMuxBearer (ConnectionId SockAddr) (TraceSendRecv (Handshake HydraVersionedProtocolNumber Term)) -> [Pair] Source #
encodeTraceSendRecvFireForget :: forall msg. ToJSON msg => TraceSendRecv (FireForget msg) -> [Pair] Source #
data HydraNetworkConfig Source #
Instances
data HydraVersionedProtocolData Source #
Instances
hydraVersionedProtocolCodec :: CodecCBORTerm (String, Maybe Int) HydraVersionedProtocolNumber Source #
hydraVersionedProtocolDataCodec :: VersionDataCodec Term HydraVersionedProtocolNumber HydraVersionedProtocolData Source #