-
Notifications
You must be signed in to change notification settings - Fork 40
/
mod.rs
66 lines (58 loc) · 1.72 KB
/
mod.rs
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
mod chainsync;
mod transport;
use serde::Deserialize;
use std::time::Duration;
use crate::{bootstrap, crosscut, model, storage};
use gasket::messaging::OutputPort;
#[derive(Deserialize)]
pub struct Config {
pub path: String,
}
impl Config {
pub fn bootstrapper(
self,
chain: &crosscut::ChainWellKnownInfo,
intersect: &crosscut::IntersectConfig,
) -> Bootstrapper {
Bootstrapper {
config: self,
intersect: intersect.clone(),
chain: chain.clone(),
output: Default::default(),
}
}
}
pub struct Bootstrapper {
config: Config,
intersect: crosscut::IntersectConfig,
chain: crosscut::ChainWellKnownInfo,
output: OutputPort<model::RawBlockPayload>,
}
impl Bootstrapper {
pub fn borrow_output_port(&mut self) -> &'_ mut OutputPort<model::RawBlockPayload> {
&mut self.output
}
pub fn spawn_stages(self, pipeline: &mut bootstrap::Pipeline, cursor: storage::Cursor) {
pipeline.register_stage(gasket::runtime::spawn_stage(
self::chainsync::Worker::new(
self.config.path.clone(),
0,
self.chain,
self.intersect,
cursor,
self.output,
),
gasket::runtime::Policy {
tick_timeout: Some(Duration::from_secs(600)),
bootstrap_retry: gasket::retries::Policy {
max_retries: 20,
backoff_factor: 2,
backoff_unit: Duration::from_secs(1),
max_backoff: Duration::from_secs(60),
},
..Default::default()
},
Some("n2c"),
));
}
}