1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Implementation of the Ouroboros networking stack.
//!
//! A multiplexer plus state-machines for each Cardano mini-protocol
//! (handshake, chain-sync, block-fetch, tx-submission, local-state-query,
//! …), exposed through ergonomic per-role facades. Async, tokio-backed.
//!
//! This is the original, single-connection / client-server-shaped stack. A
//! peer-to-peer rewrite is in progress in `pallas-network2`; once that is
//! mature it is intended to replace this crate.
//!
//! # Usage
//!
//! ```no_run
//! use pallas_network::facades::PeerClient;
//! use pallas_network::miniprotocols::MAINNET_MAGIC;
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let mut peer = PeerClient::connect(
//! "relays-new.cardano-mainnet.iohk.io:3001",
//! MAINNET_MAGIC,
//! ).await?;
//!
//! let _chainsync = peer.chainsync(); // &mut chainsync::N2NClient
//! let _blockfetch = peer.blockfetch(); // &mut blockfetch::Client
//! # Ok(()) }
//! ```
//!
//! # Overview
//!
//! - [`facades`] — opinionated client / server bundles per role:
//! [`facades::PeerClient`] / [`facades::PeerServer`] (N2N),
//! [`facades::NodeClient`] / [`facades::NodeServer`] (N2C),
//! [`facades::DmqClient`] / [`facades::DmqServer`]. Each owns a
//! multiplexer and exposes the relevant mini-protocols through accessor
//! methods.
//! - [`multiplexer`] — the segment-level transport:
//! [`multiplexer::RunningPlexer`], [`multiplexer::Bearer`].
//! - [`miniprotocols`] — every Ouroboros mini-protocol: `handshake`,
//! `chainsync`, `blockfetch`, `txsubmission`, `localstate`,
//! `localtxsubmission`, `txmonitor`, `keepalive`, `peersharing`,
//! `localmsgnotification`, `localmsgsubmission`. Network-magic constants
//! ([`miniprotocols::MAINNET_MAGIC`], [`miniprotocols::TESTNET_MAGIC`],
//! [`miniprotocols::PREVIEW_MAGIC`], [`miniprotocols::PREPROD_MAGIC`],
//! [`miniprotocols::SANCHONET_MAGIC`]) are re-exported from this module.
//!
//! # Usage as part of `pallas`
//!
//! When depending on the umbrella [`pallas`] crate, this crate is re-exported
//! as `pallas::network`.
//!
//! [`pallas`]: https://crates.io/crates/pallas
/// High-level client/server facades (node-to-node, node-to-client).
/// State-machines for every Ouroboros mini-protocol (handshake, chain-sync,
/// block-fetch, tx-submission, local-state-query, …) and the shared
/// network-magic constants.
/// Segment-level transport that multiplexes mini-protocol traffic over a
/// single bearer.