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 :: (ToCBOR msg, ToJSON msg, FromJSON msg, FromCBOR msg) => Tracer IO (LogEntry tx msg) -> ConnectionMessages IO -> NetworkConfiguration IO -> NetworkComponent IO (Authenticated msg) msg ()
- withFlipHeartbeats :: NetworkComponent m (Authenticated (Heartbeat msg)) msg1 a -> NetworkComponent m (Heartbeat (Authenticated msg)) msg1 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 | |
|
:: (ToCBOR msg, ToJSON msg, FromJSON msg, FromCBOR msg) | |
=> Tracer IO (LogEntry tx msg) | Tracer to use for logging messages. |
-> ConnectionMessages IO | Callback/observer for connectivity changes in peers. |
-> NetworkConfiguration IO | The network configuration |
-> NetworkComponent IO (Authenticated msg) msg () | Produces a |
Starts the network layer of a node, passing configured Network
to its continuation.
withFlipHeartbeats :: NetworkComponent m (Authenticated (Heartbeat msg)) msg1 a -> NetworkComponent m (Heartbeat (Authenticated msg)) msg1 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.