@@ -73,12 +73,16 @@ pub mod store;
73
73
use {
74
74
self :: {
75
75
config:: Config ,
76
- pythd:: api:: rpc,
76
+ pythd:: {
77
+ adapter:: notifier,
78
+ api:: rpc,
79
+ } ,
77
80
solana:: network,
78
81
} ,
79
82
anyhow:: Result ,
80
83
futures_util:: future:: join_all,
81
84
slog:: Logger ,
85
+ std:: sync:: Arc ,
82
86
tokio:: sync:: {
83
87
broadcast,
84
88
mpsc,
@@ -113,8 +117,7 @@ impl Agent {
113
117
114
118
// Create the channels
115
119
// TODO: make all components listen to shutdown signal
116
- let ( shutdown_tx, shutdown_rx) =
117
- broadcast:: channel ( self . config . channel_capacities . shutdown ) ;
120
+ let ( shutdown_tx, _) = broadcast:: channel ( self . config . channel_capacities . shutdown ) ;
118
121
let ( primary_oracle_updates_tx, primary_oracle_updates_rx) =
119
122
mpsc:: channel ( self . config . channel_capacities . primary_oracle_updates ) ;
120
123
let ( secondary_oracle_updates_tx, secondary_oracle_updates_rx) =
@@ -123,8 +126,6 @@ impl Agent {
123
126
mpsc:: channel ( self . config . channel_capacities . global_store_lookup ) ;
124
127
let ( local_store_tx, local_store_rx) =
125
128
mpsc:: channel ( self . config . channel_capacities . local_store ) ;
126
- let ( pythd_adapter_tx, pythd_adapter_rx) =
127
- mpsc:: channel ( self . config . channel_capacities . pythd_adapter ) ;
128
129
let ( primary_keypair_loader_tx, primary_keypair_loader_rx) = mpsc:: channel ( 10 ) ;
129
130
let ( secondary_keypair_loader_tx, secondary_keypair_loader_rx) = mpsc:: channel ( 10 ) ;
130
131
@@ -152,34 +153,38 @@ impl Agent {
152
153
) ?) ;
153
154
}
154
155
156
+ // Create the Pythd Adapter.
157
+ let adapter = Arc :: new ( pythd:: adapter:: Adapter :: new (
158
+ self . config . pythd_adapter . clone ( ) ,
159
+ global_store_lookup_tx. clone ( ) ,
160
+ local_store_tx. clone ( ) ,
161
+ logger. clone ( ) ,
162
+ ) ) ;
163
+
164
+ // Create the Notifier task for the Pythd RPC.
165
+ jhs. push ( tokio:: spawn ( notifier (
166
+ adapter. clone ( ) ,
167
+ shutdown_tx. subscribe ( ) ,
168
+ ) ) ) ;
169
+
155
170
// Spawn the Global Store
156
171
jhs. push ( store:: global:: spawn_store (
157
172
global_store_lookup_rx,
158
173
primary_oracle_updates_rx,
159
174
secondary_oracle_updates_rx,
160
- pythd_adapter_tx . clone ( ) ,
175
+ adapter . clone ( ) ,
161
176
logger. clone ( ) ,
162
177
) ) ;
163
178
164
179
// Spawn the Local Store
165
180
jhs. push ( store:: local:: spawn_store ( local_store_rx, logger. clone ( ) ) ) ;
166
181
167
- // Spawn the Pythd Adapter
168
- jhs. push ( pythd:: adapter:: spawn_adapter (
169
- self . config . pythd_adapter . clone ( ) ,
170
- pythd_adapter_rx,
171
- global_store_lookup_tx. clone ( ) ,
172
- local_store_tx. clone ( ) ,
173
- shutdown_tx. subscribe ( ) ,
174
- logger. clone ( ) ,
175
- ) ) ;
176
-
177
182
// Spawn the Pythd API Server
178
183
jhs. push ( tokio:: spawn ( rpc:: run (
179
184
self . config . pythd_api_server . clone ( ) ,
180
185
logger. clone ( ) ,
181
- pythd_adapter_tx ,
182
- shutdown_rx ,
186
+ adapter ,
187
+ shutdown_tx . subscribe ( ) ,
183
188
) ) ) ;
184
189
185
190
// Spawn the metrics server
0 commit comments