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
use lifeline::dyn_bus::DynBus;
use lifeline::{Bus, Sender};
use component_state::state::{BridgeState, StateOptions};
use support_common::config::{Config, Names};
use support_lifeline::task::TaskStack;
use crate::bridge::PangolinRopstenBus;
use crate::bridge::PangolinRopstenConfig;
use crate::bridge::{DarwiniaEthereumMessage, EthereumScanMessage};
use crate::service::affirm::AffirmService;
use crate::service::check::CheckService;
use crate::service::extrinsics::ExtrinsicsService;
use crate::service::guard::GuardService;
use crate::service::pangolin::PangolinService;
use crate::service::redeem::RedeemService;
#[derive(Debug)]
pub struct PangolinRopstenTask {
stack: TaskStack<PangolinRopstenBus>,
}
impl PangolinRopstenTask {
pub fn name() -> &'static str {
"pangolin-ropsten"
}
}
impl PangolinRopstenTask {
pub async fn new() -> color_eyre::Result<Self> {
let state = BridgeState::new(StateOptions {
db_name: Self::name().to_string(),
})?;
let _bridge_config: PangolinRopstenConfig = Config::restore(Names::BridgePangolinRopsten)?;
let microkv = state.microkv();
crate::migrate::migrate(microkv, 3)?;
let bus = PangolinRopstenBus::default();
bus.store_resource::<BridgeState>(state);
let mut stack = TaskStack::new(bus);
stack.spawn_service::<AffirmService>()?;
stack.spawn_service::<CheckService>()?;
stack.spawn_service::<RedeemService>()?;
stack.spawn_service::<GuardService>()?;
stack.spawn_service::<PangolinService>()?;
stack.spawn_service::<ExtrinsicsService>()?;
let mut tx_scan = stack.bus().tx::<DarwiniaEthereumMessage>()?;
tx_scan
.send(DarwiniaEthereumMessage::Scan(EthereumScanMessage::Start))
.await?;
Ok(Self { stack })
}
}
impl PangolinRopstenTask {
#[allow(dead_code)]
pub fn stack(&self) -> &TaskStack<PangolinRopstenBus> {
&self.stack
}
}