Skip to content

Commit 228d4e7

Browse files
committed
refactor(agent): extract exporter component/service
1 parent 96af23e commit 228d4e7

File tree

10 files changed

+1338
-136
lines changed

10 files changed

+1338
-136
lines changed

src/agent.rs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,45 +129,31 @@ impl Agent {
129129
let state = Arc::new(state::State::new(self.config.state.clone()).await);
130130

131131
// Spawn the primary network Oracle.
132-
{
133-
// Publisher permissions updates between oracle and exporter
134-
let (publisher_permissions_tx, publisher_permissions_rx) =
135-
watch::channel(<_>::default());
136-
137-
jhs.push(tokio::spawn(services::oracle(
138-
self.config.primary_network.clone(),
139-
network::Network::Primary,
140-
state.clone(),
141-
publisher_permissions_tx.clone(),
142-
)));
132+
jhs.push(tokio::spawn(services::oracle(
133+
self.config.primary_network.clone(),
134+
network::Network::Primary,
135+
state.clone(),
136+
)));
143137

144-
// Spawn the primary network
145-
jhs.extend(network::spawn_network(
146-
self.config.primary_network.clone(),
147-
network::Network::Primary,
148-
state.clone(),
149-
publisher_permissions_rx.clone(),
150-
)?);
151-
}
138+
jhs.push(tokio::spawn(services::exporter(
139+
self.config.primary_network.clone(),
140+
network::Network::Primary,
141+
state.clone(),
142+
)));
152143

153144
// Spawn the secondary network Oracle, if needed.
154145
if let Some(config) = &self.config.secondary_network {
155-
let (publisher_permissions_tx, publisher_permissions_rx) =
156-
watch::channel(<_>::default());
157-
158146
jhs.push(tokio::spawn(services::oracle(
159147
config.clone(),
160148
network::Network::Secondary,
161149
state.clone(),
162-
publisher_permissions_tx.clone(),
163150
)));
164151

165-
jhs.extend(network::spawn_network(
152+
jhs.push(tokio::spawn(services::exporter(
166153
config.clone(),
167154
network::Network::Secondary,
168155
state.clone(),
169-
publisher_permissions_rx,
170-
)?);
156+
)));
171157
}
172158

173159
// Create the Notifier task for the Pythd RPC.

src/agent/services.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
pub mod exporter;
12
pub mod keypairs;
23
pub mod notifier;
34
pub mod oracle;
45

56
pub use {
7+
exporter::exporter,
68
keypairs::keypairs,
79
notifier::notifier,
810
oracle::oracle,

0 commit comments

Comments
 (0)