Skip to content

Commit 1fda7fa

Browse files
committed
refactor(agent): convert keypair service to api
1 parent 0cd76df commit 1fda7fa

File tree

6 files changed

+301
-372
lines changed

6 files changed

+301
-372
lines changed

src/agent.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pub mod legacy_schedule;
6666
pub mod market_schedule;
6767
pub mod metrics;
6868
pub mod pythd;
69-
pub mod remote_keypair_loader;
7069
pub mod solana;
7170
pub mod state;
7271
pub mod store;
@@ -81,10 +80,7 @@ use {
8180
futures_util::future::join_all,
8281
slog::Logger,
8382
std::sync::Arc,
84-
tokio::sync::{
85-
broadcast,
86-
mpsc,
87-
},
83+
tokio::sync::broadcast,
8884
};
8985

9086
pub struct Agent {
@@ -116,8 +112,6 @@ impl Agent {
116112
// Create the channels
117113
// TODO: make all components listen to shutdown signal
118114
let (shutdown_tx, _) = broadcast::channel(self.config.channel_capacities.shutdown);
119-
let (primary_keypair_loader_tx, primary_keypair_loader_rx) = mpsc::channel(10);
120-
let (secondary_keypair_loader_tx, secondary_keypair_loader_rx) = mpsc::channel(10);
121115

122116
// Create the Pythd Adapter.
123117
let adapter =
@@ -127,7 +121,6 @@ impl Agent {
127121
jhs.extend(network::spawn_network(
128122
self.config.primary_network.clone(),
129123
network::Network::Primary,
130-
primary_keypair_loader_tx,
131124
logger.new(o!("primary" => true)),
132125
adapter.clone(),
133126
)?);
@@ -137,7 +130,6 @@ impl Agent {
137130
jhs.extend(network::spawn_network(
138131
config.clone(),
139132
network::Network::Secondary,
140-
secondary_keypair_loader_tx,
141133
logger.new(o!("primary" => false)),
142134
adapter.clone(),
143135
)?);
@@ -161,21 +153,20 @@ impl Agent {
161153
jhs.push(tokio::spawn(metrics::MetricsServer::spawn(
162154
self.config.metrics_server.bind_address,
163155
logger.clone(),
164-
adapter,
156+
adapter.clone(),
165157
)));
166158

167159
// Spawn the remote keypair loader endpoint for both networks
168160
jhs.append(
169-
&mut remote_keypair_loader::RemoteKeypairLoader::spawn(
170-
primary_keypair_loader_rx,
171-
secondary_keypair_loader_rx,
161+
&mut state::keypairs::spawn(
172162
self.config.primary_network.rpc_url.clone(),
173163
self.config
174164
.secondary_network
175165
.as_ref()
176166
.map(|c| c.rpc_url.clone()),
177167
self.config.remote_keypair_loader.clone(),
178168
logger,
169+
adapter,
179170
)
180171
.await,
181172
);
@@ -192,7 +183,6 @@ pub mod config {
192183
super::{
193184
metrics,
194185
pythd,
195-
remote_keypair_loader,
196186
solana::network,
197187
state,
198188
},
@@ -220,7 +210,7 @@ pub mod config {
220210
#[serde(default)]
221211
pub metrics_server: metrics::Config,
222212
#[serde(default)]
223-
pub remote_keypair_loader: remote_keypair_loader::Config,
213+
pub remote_keypair_loader: state::keypairs::Config,
224214
}
225215

226216
impl Config {

0 commit comments

Comments
 (0)