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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Zero-config tunables for the consumption faces over the paid pull engine
//! (`Downloader`, `Streamer`, #1848).
//!
//! [`PullConfig`] holds only tunables, each with a sensible default. The REQUIRED
//! per-fetch inputs — identity, the connection, the spend budget, the provider
//! set — are not here; they flow through the engine's existing params
//! ([`crate::PoolContext`], the [`iroh::Endpoint`], discovered candidates). That
//! split is what lets a `PullConfig` construct with no network or chain access.
//!
//! The payment interval is deliberately NOT a tunable: it is the fixed protocol
//! constant [`decdn_protocol::client::CHUNK_BYTES`] (1 MiB, #1676).
/// Default [`PullConfig::read_ahead_bytes`]: 16 MiB — sixteen 1 MiB payment
/// intervals of buffering. Enough to keep a consumer's buffer full without
/// fetching (and paying for) far past where it might stop reading.
pub const DEFAULT_READ_AHEAD_BYTES: u64 = 16 * 1024 * 1024;
/// Default [`PullConfig::streamer_lane_cap`]: two. A `Streamer` keeps a small,
/// bounded set of provider lanes on the front — enough for same-region fan-out,
/// without the wide fan-out a full download wants. The `Downloader` runs one
/// lane per holder instead.
pub const DEFAULT_STREAMER_LANE_CAP: usize = 2;
/// Zero-config tunables shared by the consumption faces.
///
/// Overrides are opt-in: [`PullConfig::default`] is the whole configuration a
/// caller needs. Override a field with struct-update syntax:
///
/// ```
/// use decdn_client::PullConfig;
///
/// // Let a stream run 64 MiB ahead of its reader instead of the default.
/// let config = PullConfig {
/// read_ahead_bytes: 64 * 1024 * 1024,
/// ..PullConfig::new()
/// };
/// assert_eq!(config.streamer_lane_cap, PullConfig::new().streamer_lane_cap);
/// ```