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 16
16
profile : minimal
17
17
toolchain : nightly
18
18
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 1
1
use {
2
2
crate :: agent:: state,
3
- anyhow:: Result ,
3
+ anyhow:: {
4
+ anyhow,
5
+ Result ,
6
+ } ,
4
7
futures_util:: {
5
8
stream:: {
6
9
SplitSink ,
@@ -135,7 +138,7 @@ struct SymbolResponse {
135
138
136
139
async fn fetch_symbols ( history_url : & Url ) -> Result < Vec < SymbolResponse > > {
137
140
let mut url = history_url. clone ( ) ;
138
- url. set_scheme ( "http" ) . unwrap ( ) ;
141
+ url. set_scheme ( "http" ) . map_err ( |_| anyhow ! ( "invalid url" ) ) ? ;
139
142
url. set_path ( "/history/v1/symbols" ) ;
140
143
let client = Client :: new ( ) ;
141
144
let response = client. get ( url) . send ( ) . await ?. error_for_status ( ) ?;
@@ -181,6 +184,7 @@ mod lazer_exporter {
181
184
time:: Duration ,
182
185
} ,
183
186
tokio_stream:: StreamMap ,
187
+ tracing:: warn,
184
188
} ;
185
189
186
190
pub async fn lazer_exporter < S > ( config : Config , state : Arc < S > )
@@ -245,8 +249,14 @@ mod lazer_exporter {
245
249
// TODO: This read locks and clones local::Store::prices, which may not meet performance needs.
246
250
for ( identifier, price_info) in state. get_all_price_infos( ) . await {
247
251
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
+ } ;
248
258
if let Err ( e) = relayer_sender. send_price_update( & PriceFeedDataV1 {
249
- price: Some ( Price ( NonZeroI64 :: try_from ( price_info . price ) . unwrap ( ) ) ) ,
259
+ price,
250
260
best_ask_price: None ,
251
261
best_bid_price: None ,
252
262
price_feed_id: PriceFeedId ( symbol. pyth_lazer_id) ,
You can’t perform that action at this time.
0 commit comments