|
4 | 4 | clap::Parser, |
5 | 5 | posted_message::PostedMessageUnreliableData, |
6 | 6 | secp256k1::SecretKey, |
| 7 | + serde_wormhole::RawMessage, |
7 | 8 | solana_account_decoder::UiAccountEncoding, |
8 | 9 | solana_client::{ |
9 | 10 | nonblocking::pubsub_client::PubsubClient, |
@@ -93,31 +94,30 @@ async fn run_listener(input: RunListenerInput) -> Result<(), PubsubClientError> |
93 | 94 | continue; |
94 | 95 | } |
95 | 96 |
|
96 | | - let body = Body { |
97 | | - timestamp: unreliable_data.submission_time, |
98 | | - nonce: unreliable_data.nonce, |
99 | | - emitter_chain: unreliable_data.emitter_chain.into(), |
100 | | - emitter_address: Address(unreliable_data.emitter_address), |
101 | | - sequence: unreliable_data.sequence, |
102 | | - consistency_level: unreliable_data.consistency_level, |
103 | | - payload: unreliable_data.payload.clone(), |
104 | | - }; |
105 | | - |
106 | | - match Observation::try_new(body, input.secret_key) { |
107 | | - Ok(observation) => { |
108 | | - tokio::spawn({ |
109 | | - let api_client = input.api_client.clone(); |
110 | | - async move { |
| 97 | + tokio::spawn({ |
| 98 | + let api_client = input.api_client.clone(); |
| 99 | + async move { |
| 100 | + let body = Body { |
| 101 | + timestamp: unreliable_data.submission_time, |
| 102 | + nonce: unreliable_data.nonce, |
| 103 | + emitter_chain: unreliable_data.emitter_chain.into(), |
| 104 | + emitter_address: Address(unreliable_data.emitter_address), |
| 105 | + sequence: unreliable_data.sequence, |
| 106 | + consistency_level: unreliable_data.consistency_level, |
| 107 | + payload: RawMessage::new(unreliable_data.payload.as_slice()), |
| 108 | + }; |
| 109 | + match Observation::try_new(body.clone(), input.secret_key) { |
| 110 | + Ok(observation) => { |
111 | 111 | if let Err(e) = api_client.post_observation(observation).await { |
112 | 112 | tracing::error!(error = ?e, "Failed to post observation"); |
113 | 113 | } else { |
114 | 114 | tracing::info!("Observation posted successfully"); |
115 | | - } |
| 115 | + }; |
116 | 116 | } |
117 | | - }); |
| 117 | + Err(e) => tracing::error!(error = ?e, "Failed to create observation"), |
| 118 | + } |
118 | 119 | } |
119 | | - Err(e) => tracing::error!(error = ?e, "Failed to create observation"), |
120 | | - }; |
| 120 | + }); |
121 | 121 | } |
122 | 122 |
|
123 | 123 | tokio::spawn(async move { unsubscribe().await }); |
|
0 commit comments