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
//! # Shared environment bundle for all protocol participants
//!
//! One struct — [`RuntimeServices`] — wraps every environment-dependent trait object
//! that a client or server needs to participate in the protocol: the clock
//! ([`TimeProvider`]), the network ([`TransportFactory`]), and the PoW engine
//! ([`PowGenerator`]).
//!
//! Every layer of the crate takes its dependencies through a shared
//! `Arc<RuntimeServices>` instead of reaching for concrete implementations directly.
//! This is the seam that makes the in-memory integration tests work: swap the
//! `TransportFactory` for [`MemTransportFactory`], the `TimeProvider` for a virtual
//! clock, the `PowGenerator` for [`SingleThreadedPowGenerator`], and an entire
//! hashiverse network can run deterministically inside a single test binary.
use cratePowGenerator;
use crateSingleThreadedPowGenerator;
use crate;
use crateTransportFactory;
use Arc;
use crateMemTransportFactory;
/// The bundle of environment-dependent services that both clients and servers need to
/// participate in the protocol.
///
/// Every layer of the crate — transport, protocol, client, server — takes its dependencies
/// through a shared `RuntimeServices` rather than reaching out to concrete clock /
/// network / PoW implementations directly. This is the seam that makes the in-memory
/// integration tests possible: swap [`TransportFactory`] for an in-memory one, [`TimeProvider`]
/// for a virtual clock, and [`PowGenerator`] for a single-threaded stub, and an entire
/// hashiverse network can run deterministically inside a single test binary.
///
/// In production, [`crate::client::hashiverse_client::HashiverseClient`] and the server
/// binary each construct a `RuntimeServices` with the real implementations of these traits
/// and pass the same `Arc<RuntimeServices>` down through every constructor that needs it.