{-# LANGUAGE NamedFieldPuns #-}

module Ouroboros.Network.Protocol.PeerSharing.Direct where

import Ouroboros.Network.Protocol.PeerSharing.Client
import Ouroboros.Network.Protocol.PeerSharing.Server

direct :: Monad m
       => PeerSharingServer peer m
       -> PeerSharingClient peer m b
       -> m b
direct :: forall (m :: * -> *) peer b.
Monad m =>
PeerSharingServer peer m -> PeerSharingClient peer m b -> m b
direct PeerSharingServer {}
       (SendMsgDone m b
mdone) = m b
mdone
direct PeerSharingServer { PeerSharingAmount -> m ([peer], PeerSharingServer peer m)
recvMsgShareRequest :: PeerSharingAmount -> m ([peer], PeerSharingServer peer m)
recvMsgShareRequest :: forall peerAddress (m :: * -> *).
PeerSharingServer peerAddress m
-> PeerSharingAmount
-> m ([peerAddress], PeerSharingServer peerAddress m)
recvMsgShareRequest }
       (SendMsgShareRequest PeerSharingAmount
amount [peer] -> m (PeerSharingClient peer m b)
mclient) = do
    (peers, server) <- PeerSharingAmount -> m ([peer], PeerSharingServer peer m)
recvMsgShareRequest PeerSharingAmount
amount
    client <- mclient peers
    direct server client