Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Concrete Network
stack dedicated to running a hydra-node.
This module provides a withNetwork
function which is the composition of several layers in order to provide various capabilities:
withHeartbeat
maintains knowledge about peers' connectivity,withReliability
deals with connections reliability, handling the case of messages being dropped (but not node crash in general),withAuthentication
handles messages' authentication and signature verification,withOuroborosNetwork
deals with maintaining individual connections to peers and the nitty-gritty details of messages sending and retrieval.
The following diagram details the various types of messages each layer is exchanging with its predecessors and successors.
▲ │ │ Authenticate msg │ msg │ │ ┌────────┴────────────────────────────────────▼──────┐ │ │ │ Heartbeat │ │ ▲ │ └────────┬────────────────────────────────────┼──────┘ │ │ │ Heartbeat (Authenticate msg) │ Heartbeat msg │ │ ┌────────┴───────────────┐ │ │ │ │ │ FlipHeartbeats │ │ │ │ │ └────────▲───────────────┘ │ │ │ │ Authenticate (Heartbeat msg) │ │ │ ┌────────┴────────────────────────────────────▼──────┐ │ │ │ Reliability │ │ │ └─────────▲───────────────────────────────────┼──────┘ │ │ Authenticated (ReliableMsg (Heartbeat msg)) ReliableMsg (Heartbeat msg) │ │ ┌─────────┼───────────────────────────────────▼──────┐ │ │ │ Authenticate │ │ │ └─────────▲───────────────────────────────────┼──────┘ │ │ │ │ Signed (ReliableMsg (Heartbeat msg)) Signed (ReliableMsg (Heartbeat msg)) │ │ ┌─────────┼───────────────────────────────────▼──────┐ │ │ │ Ouroboros │ │ │ └─────────▲───────────────────────────────────┼──────┘ │ │ │ (bytes) │ │ ▼
Synopsis
- data NetworkConfiguration m = NetworkConfiguration {
- persistenceDir :: FilePath
- signingKey :: SigningKey HydraKey
- otherParties :: [Party]
- host :: IP
- port :: PortNumber
- peers :: [Host]
- nodeId :: NodeId
- withNetwork :: forall tx. IsTx tx => Tracer IO (LogEntry tx (Message tx)) -> NetworkConfiguration IO -> NetworkComponent IO (NetworkEvent (Message tx)) (Message tx) ()
- withFlipHeartbeats :: NetworkComponent m (Authenticated (Heartbeat inbound)) outbound a -> NetworkComponent m (Heartbeat (Authenticated inbound)) outbound a
- configureMessagePersistence :: (MonadIO m, MonadThrow m, FromJSON msg, ToJSON msg, MonadSTM m, MonadThread m, MonadThrow (STM m)) => Tracer m (HydraNodeLog tx) -> FilePath -> Int -> m (MessagePersistence m msg)
- acksFile :: FilePath -> FilePath
Documentation
data NetworkConfiguration m Source #
Configuration for a Node
network layer.
NetworkConfiguration | |
|
:: forall tx. IsTx tx | |
=> Tracer IO (LogEntry tx (Message tx)) | Tracer to use for logging messages. |
-> NetworkConfiguration IO | The network configuration |
-> NetworkComponent IO (NetworkEvent (Message tx)) (Message tx) () | Produces a |
Starts the network layer of a node, passing configured Network
to its continuation.
withFlipHeartbeats :: NetworkComponent m (Authenticated (Heartbeat inbound)) outbound a -> NetworkComponent m (Heartbeat (Authenticated inbound)) outbound a Source #
configureMessagePersistence :: (MonadIO m, MonadThrow m, FromJSON msg, ToJSON msg, MonadSTM m, MonadThread m, MonadThrow (STM m)) => Tracer m (HydraNodeLog tx) -> FilePath -> Int -> m (MessagePersistence m msg) Source #
Create MessagePersistence
handle to be used by Reliability
network layer.
This function will throw
a ParameterMismatch
exception if:
- Some state already exists and is loaded,
- The number of parties is not the same as the number of acknowledgments saved.