hydra-node-0.17.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Node.Network

Description

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

Documentation

data NetworkConfiguration m Source #

Configuration for a Node network layer.

Constructors

NetworkConfiguration 

Fields

withNetwork Source #

Arguments

:: forall msg tx. (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 NetworkComponent that can send msg and consumes Authenticated msg.

Starts the network layer of a node, passing configured Network to its continuation.

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.

acksFile :: FilePath -> FilePath Source #

Where is the acknowledgments vector stored, relative to given directory.