Skip to content

Commit

Permalink
fix teeracle treading
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Feb 2, 2025
1 parent d554c2b commit dcd6471
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app-libs/oracle/src/metrics_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
fn record_response_time(&self, source: String, timer: Instant) {
self.update_metrics(vec![ExchangeRateOracleMetric::ResponseTime(
source,
timer.elapsed().as_millis(),
timer.elapsed().as_secs().into(),
)]);
}

Expand Down
41 changes: 19 additions & 22 deletions service/src/teeracle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,26 @@ where
// Send the extrinsics to the parentchain and wait for InBlock confirmation.
for call in extrinsics.into_iter() {
let node_api_clone = node_api.clone();
tokio_handle.spawn(async move {
let encoded_extrinsic = call.encode();
debug!("Hex encoded extrinsic to be sent: {}", hex_encode(&encoded_extrinsic));

println!("[>] Update oracle data (send the extrinsic)");
let extrinsic_hash = match node_api_clone.submit_and_watch_opaque_extrinsic_until(
&encoded_extrinsic.into(),
XtStatus::InBlock,
) {
Err(e) => {
error!("Failed to send extrinsic: {:?}", e);
set_extrinsics_inclusion_success(false);
return
},
Ok(report) => {
set_extrinsics_inclusion_success(true);
let encoded_extrinsic = call.encode();
debug!("Hex encoded extrinsic to be sent: {}", hex_encode(&encoded_extrinsic));

println!("[>] Update oracle data (send the extrinsic)");
match node_api_clone
.submit_and_watch_opaque_extrinsic_until(&encoded_extrinsic.into(), XtStatus::InBlock)
{
Err(e) => {
error!("Failed to send extrinsic: {:?}", e);
set_extrinsics_inclusion_success(false);
continue
},
Ok(report) => {
set_extrinsics_inclusion_success(true);
println!(
"[<] Extrinsic got included into a block. Hash: {:?}\n",
report.extrinsic_hash
},
};

println!("[<] Extrinsic got included into a block. Hash: {:?}\n", extrinsic_hash);
});
);
},
};
}

Ok(())
}
2 changes: 1 addition & 1 deletion service/src/teeracle/teeracle_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lazy_static! {
register_gauge_vec!("integritee_teeracle_exchange_rate", "Exchange rates partitioned into source and trading pair", &["source", "trading_pair"])
.unwrap();
static ref RESPONSE_TIME: IntGaugeVec =
register_int_gauge_vec!("integritee_teeracle_response_times", "Response times in ms for requests that the oracle makes", &["source"])
register_int_gauge_vec!("integritee_teeracle_response_times", "Response times in for requests that the oracle makes [s]", &["source"])
.unwrap();
static ref NUMBER_OF_REQUESTS: IntCounterVec =
register_int_counter_vec!("integritee_teeracle_number_of_requests", "Number of requests made per source", &["source"])
Expand Down

0 comments on commit dcd6471

Please sign in to comment.