File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 1616 profile : minimal
1717 toolchain : nightly
1818 components : rustfmt
19- - uses : pre-commit/action@v2 .0.3
19+ - uses : pre-commit/action@v3 .0.1
Original file line number Diff line number Diff line change 11use {
22 crate :: agent:: state,
3- anyhow:: Result ,
3+ anyhow:: {
4+ anyhow,
5+ Result ,
6+ } ,
47 futures_util:: {
58 stream:: {
69 SplitSink ,
@@ -135,7 +138,7 @@ struct SymbolResponse {
135138
136139async fn fetch_symbols ( history_url : & Url ) -> Result < Vec < SymbolResponse > > {
137140 let mut url = history_url. clone ( ) ;
138- url. set_scheme ( "http" ) . unwrap ( ) ;
141+ url. set_scheme ( "http" ) . map_err ( |_| anyhow ! ( "invalid url" ) ) ? ;
139142 url. set_path ( "/history/v1/symbols" ) ;
140143 let client = Client :: new ( ) ;
141144 let response = client. get ( url) . send ( ) . await ?. error_for_status ( ) ?;
@@ -181,6 +184,7 @@ mod lazer_exporter {
181184 time:: Duration ,
182185 } ,
183186 tokio_stream:: StreamMap ,
187+ tracing:: warn,
184188 } ;
185189
186190 pub async fn lazer_exporter < S > ( config : Config , state : Arc < S > )
@@ -245,8 +249,14 @@ mod lazer_exporter {
245249 // TODO: This read locks and clones local::Store::prices, which may not meet performance needs.
246250 for ( identifier, price_info) in state. get_all_price_infos( ) . await {
247251 if let Some ( symbol) = lazer_symbols. get( & identifier. to_string( ) ) {
252+ let price = if let Ok ( price) = NonZeroI64 :: try_from( price_info. price) {
253+ Some ( Price ( price) )
254+ } else {
255+ warn!( "Zero price in local state identifier: {identifier} price_info: {price_info:?}" ) ;
256+ continue ;
257+ } ;
248258 if let Err ( e) = relayer_sender. send_price_update( & PriceFeedDataV1 {
249- price: Some ( Price ( NonZeroI64 :: try_from ( price_info . price ) . unwrap ( ) ) ) ,
259+ price,
250260 best_ask_price: None ,
251261 best_bid_price: None ,
252262 price_feed_id: PriceFeedId ( symbol. pyth_lazer_id) ,
You can’t perform that action at this time.
0 commit comments