network-mux
Safe HaskellNone
LanguageHaskell2010

Network.Mux.Ingress

Synopsis

Documentation

Ingress Path

                 ●
                 │
                 │ ByteStrings
                 │
        ░░░░░░░░░▼░░░░░░░░░
        ░┌───────────────┐░
        ░│ Bearer.read() │░ Mux Bearer implementation (Socket, Pipes, etc.)
        ░└───────────────┘░
        ░░░░░░░░░│░░░░░░░░░
                ░│░         SDUs
        ░░░░░░░░░▼░░░░░░░░░
        ░┌───────────────┐░
        ░│     demux     │░ For a given Mux Bearer there is a single demux
        ░└───────┬───────┘░ thread reading from the underlying bearer.
        ░░░░░░░░░│░░░░░░░░░
                ░│░
       ░░░░░░░░░░▼░░░░░░░░░░
       ░ ╭────┬────┬─────╮ ░ There is a limited queue (in bytes) for each mode
       ░ │    │    │     │ ░ (responder/initiator) per miniprotocol. Overflowing
       ░ ▼    ▼    ▼     ▼ ░ a queue is a protocol violation and a
       ░│  │ │  │ │  │ │  │░ IngressQueueOverRun exception is thrown
       ░│ci│ │  │ │bi│ │br│░ and the bearer torn down.
       ░│ci│ │cr│ │bi│ │br│░
       ░└──┘ └──┘ └──┘ └──┘░ Every ingress queue has a dedicated thread which will
       ░░│░░░░│░░░░│░░░░│░░░ read application encoded data from its queue.
         │    │    │    │
          application data
         │    │    │    │
         ▼    │    │    ▼
┌───────────┐ │    │  ┌───────────┐
│ muxDuplex │ │    │  │ muxDuplex │
│ Initiator │ │    │  │ Responder │
│ ChainSync │ │    │  │ BlockFetch│
└───────────┘ │    │  └───────────┘
              ▼    ▼
   ┌───────────┐  ┌───────────┐
   │ muxDuplex │  │ muxDuplex │
   │ Responder │  │ Initiator │
   │ ChainSync │  │ BlockFetch│
   └───────────┘  └───────────┘

demuxer :: forall m (mode :: Mode) void. (MonadAsync m, MonadFork m, MonadMask m, MonadThrow (STM m), MonadTimer m) => [MiniProtocolState mode m] -> Bearer m -> m void Source #

demux runs as a single separate thread and reads complete SDUs from the underlying Bearer and forwards it to the matching ingress queue.