@@ -41,7 +41,7 @@ struct RunListenerInput<T: Signer> {
41
41
signer : T ,
42
42
wormhole_pid : Pubkey ,
43
43
accumulator_address : Pubkey ,
44
- api_client : ApiClient ,
44
+ api_clients : Vec < ApiClient > ,
45
45
}
46
46
47
47
fn find_message_pda ( wormhole_pid : & Pubkey , slot : u64 ) -> Pubkey {
@@ -147,21 +147,27 @@ async fn run_listener<T: Signer + 'static>(
147
147
Err ( _) => continue ,
148
148
} ;
149
149
150
- tokio:: spawn ( {
151
- let ( api_client, signer) = ( input. api_client . clone ( ) , input. signer . clone ( ) ) ;
152
- async move {
153
- let body = message_data_to_body ( & unreliable_data) ;
154
- match Observation :: try_new ( body. clone ( ) , signer. clone ( ) ) {
155
- Ok ( observation) => {
156
- if let Err ( e) = api_client. post_observation ( observation) . await {
157
- tracing:: error!( error = ?e, "Failed to post observation" ) ;
158
- } else {
159
- tracing:: info!( "Observation posted successfully" ) ;
160
- } ;
150
+ input. api_clients . iter ( ) . for_each ( |api_client| {
151
+ tokio:: spawn ( {
152
+ let ( unreliable_data, api_client, signer) = (
153
+ unreliable_data. clone ( ) ,
154
+ api_client. clone ( ) ,
155
+ input. signer . clone ( )
156
+ ) ;
157
+ async move {
158
+ let body = message_data_to_body ( & unreliable_data) ;
159
+ match Observation :: try_new ( body. clone ( ) , signer. clone ( ) ) {
160
+ Ok ( observation) => {
161
+ if let Err ( e) = api_client. post_observation ( observation) . await {
162
+ tracing:: error!( url = api_client. get_base_url( ) . to_string( ) , error = ?e, "Failed to post observation" ) ;
163
+ } else {
164
+ tracing:: info!( url = api_client. get_base_url( ) . to_string( ) , "Observation posted successfully" ) ;
165
+ } ;
166
+ }
167
+ Err ( e) => tracing:: error!( error = ?e, "Failed to create observation" ) ,
161
168
}
162
- Err ( e) => tracing:: error!( error = ?e, "Failed to create observation" ) ,
163
169
}
164
- }
170
+ } ) ;
165
171
} ) ;
166
172
}
167
173
@@ -182,8 +188,13 @@ async fn run(run_options: config::RunOptions) {
182
188
. expect ( "Invalid accumulator address" ) ;
183
189
let wormhole_pid =
184
190
Pubkey :: from_str ( & run_options. wormhole_pid ) . expect ( "Invalid Wormhole program ID" ) ;
185
- let api_client =
186
- ApiClient :: try_new ( run_options. server_url , None ) . expect ( "Failed to create API client" ) ;
191
+ let api_clients: Vec < ApiClient > = run_options
192
+ . server_urls
193
+ . into_iter ( )
194
+ . map ( |server_url| {
195
+ ApiClient :: try_new ( server_url, None ) . expect ( "Failed to create API client" )
196
+ } )
197
+ . collect ( ) ;
187
198
188
199
let ( pubkey, pubkey_evm) = signer. get_public_key ( ) . expect ( "Failed to get public key" ) ;
189
200
let evm_encded_public_key = format ! ( "0x{}" , hex:: encode( pubkey_evm) ) ;
@@ -199,7 +210,7 @@ async fn run(run_options: config::RunOptions) {
199
210
signer : signer. clone ( ) ,
200
211
wormhole_pid,
201
212
accumulator_address,
202
- api_client : api_client . clone ( ) ,
213
+ api_clients : api_clients . clone ( ) ,
203
214
} )
204
215
. await
205
216
{
0 commit comments