Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ouroboros.Network.PeerSharing
Synopsis
- newtype PeerSharingController peer m = PeerSharingController {
- requestQueue :: StrictTMVar m (PeerSharingAmount, MVar m [peer])
- newtype PeerSharingRegistry peer m = PeerSharingRegistry {
- getPeerSharingRegistry :: StrictTVar m (Map peer (PeerSharingController peer m))
- newPeerSharingRegistry :: (MonadSTM m, Ord peer) => m (PeerSharingRegistry peer m)
- bracketPeerSharingClient :: (Ord peer, MonadSTM m, MonadThrow m) => PeerSharingRegistry peer m -> peer -> (PeerSharingController peer m -> m a) -> m a
- peerSharingClient :: (Alternative (STM m), MonadMVar m, MonadSTM m) => ControlMessageSTM m -> PeerSharingController peer m -> m (PeerSharingClient peer m ())
- peerSharingServer :: Monad m => (PeerSharingAmount -> m [peer]) -> PeerSharingServer peer m
Documentation
newtype PeerSharingController peer m Source #
Request and Result queue for the peer sharing client implementation.
Although Peer Sharing is a request-response protocol we can not run it as one, i.e. starting and terminating the protocol on demand since protocol termination as a different semantics. We have to keep the client and server protocol sides running and only issue the requests on demand.
A workaround to this is to implement the client side with the help of a
PeerSharingController which contains two queues: request and result.
The client side will be waiting to receive a PeerSharingAmount
from the
request queue and as soon as it gets something it will send a
SendMsgShareRequest
and wait for a response before writing it to the
result queue.
Constructors
PeerSharingController | |
Fields
|
newtype PeerSharingRegistry peer m Source #
Peer Sharing Registry is a registry that stores a PeerSharingController
for every peer that we connect to.
bracketPeerSharingClient
should be used.
Constructors
PeerSharingRegistry | |
Fields
|
newPeerSharingRegistry :: (MonadSTM m, Ord peer) => m (PeerSharingRegistry peer m) Source #
bracketPeerSharingClient :: (Ord peer, MonadSTM m, MonadThrow m) => PeerSharingRegistry peer m -> peer -> (PeerSharingController peer m -> m a) -> m a Source #
peerSharingClient :: (Alternative (STM m), MonadMVar m, MonadSTM m) => ControlMessageSTM m -> PeerSharingController peer m -> m (PeerSharingClient peer m ()) Source #
peerSharingServer :: Monad m => (PeerSharingAmount -> m [peer]) -> PeerSharingServer peer m Source #