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
use std::time::Duration;
/// Configuration for the Solana HyperSync client.
#[derive(Debug, Clone)]
pub struct ClientConfig {
/// Base URL of the HyperSync server (e.g. "https://solana.hypersync.xyz").
pub url: String,
/// Bearer token for authenticated requests.
pub bearer_token: Option<String>,
/// Timeout for individual HTTP requests.
pub http_req_timeout: Duration,
/// Maximum number of retries per request.
pub max_num_retries: u32,
/// Base delay for exponential backoff retries.
pub retry_base_ms: u64,
/// Maximum delay for exponential backoff retries.
pub retry_ceiling_ms: u64,
/// Whether to proactively sleep when the rate limit is exhausted instead of
/// sending requests that will be rejected with 429.
///
/// Enabled by default. Set to `false` to opt out and handle rate limits yourself.
pub proactive_rate_limit_sleep: bool,
}
impl Default for ClientConfig {
fn default() -> Self {
Self {
url: String::new(),
bearer_token: None,
http_req_timeout: Duration::from_secs(30),
max_num_retries: 12,
retry_base_ms: 500,
retry_ceiling_ms: 5_000,
proactive_rate_limit_sleep: true,
}
}
}
/// Configuration for concurrent streaming.
#[derive(Debug, Clone)]
pub struct StreamConfig {
/// Number of slots to request per chunk.
pub batch_size: u64,
/// Maximum batch size (for adaptive sizing).
pub max_batch_size: u64,
/// Minimum batch size (for adaptive sizing).
pub min_batch_size: u64,
/// Number of concurrent in-flight requests.
pub concurrency: usize,
/// Response byte threshold above which batch size shrinks.
pub response_bytes_ceiling: u64,
/// Response byte threshold below which batch size grows.
pub response_bytes_floor: u64,
}
impl Default for StreamConfig {
fn default() -> Self {
Self {
batch_size: 1_000,
max_batch_size: 200_000,
min_batch_size: 100,
concurrency: 10,
response_bytes_ceiling: 500_000,
response_bytes_floor: 250_000,
}
}
}