1515
1616*/
1717
18- use crate :: { error:: ServiceResult , teeracle:: interval_scheduling :: schedule_on_repeating_intervals } ;
18+ use crate :: { error:: ServiceResult , teeracle:: schedule_periodic :: schedule_periodic } ;
1919use codec:: { Decode , Encode } ;
2020use itp_enclave_api:: teeracle_api:: TeeracleApi ;
2121use itp_node_api:: api_client:: ParentchainApi ;
@@ -28,7 +28,7 @@ use substrate_api_client::{SubmitAndWatch, XtStatus};
2828use teeracle_metrics:: { increment_number_of_request_failures, set_extrinsics_inclusion_success} ;
2929use tokio:: runtime:: Handle ;
3030
31- pub ( crate ) mod interval_scheduling ;
31+ pub ( crate ) mod schedule_periodic ;
3232pub ( crate ) mod teeracle_metrics;
3333
3434pub ( crate ) fn schedule_teeracle_reregistration_thread (
@@ -40,7 +40,7 @@ pub(crate) fn schedule_teeracle_reregistration_thread(
4040 std:: thread:: Builder :: new ( )
4141 . name ( "teeracle_reregistration_thread" . to_owned ( ) )
4242 . spawn ( move || {
43- schedule_on_repeating_intervals (
43+ schedule_periodic (
4444 || {
4545 println ! ( "Reregistering the teeracle." ) ;
4646 if let Some ( block_hash) = send_register_xt ( ) {
@@ -58,11 +58,12 @@ pub(crate) fn schedule_teeracle_reregistration_thread(
5858 . unwrap ( ) ;
5959}
6060
61- /// Send extrinsic to chain according to the market data update interval in the settings
62- /// with the current market data (for now only exchange rate).
63- pub ( crate ) fn start_interval_market_update < E : TeeracleApi > (
61+ /// Executes a periodic teeracle data update and sends the new data to the parentchain.
62+ ///
63+ /// Note: Puts the current thread to sleep for `period`.
64+ pub ( crate ) fn start_periodic_market_update < E : TeeracleApi > (
6465 api : & ParentchainApi ,
65- interval : Duration ,
66+ period : Duration ,
6667 enclave_api : & E ,
6768 tokio_handle : & Handle ,
6869) {
@@ -84,8 +85,8 @@ pub(crate) fn start_interval_market_update<E: TeeracleApi>(
8485 info ! ( "Teeracle will update now" ) ;
8586 updates_to_run ( ) ;
8687
87- info ! ( "Schedule teeracle updates every {:?}" , interval ) ;
88- schedule_on_repeating_intervals ( updates_to_run, interval ) ;
88+ info ! ( "Schedule teeracle updates every {:?}" , period ) ;
89+ schedule_periodic ( updates_to_run, period ) ;
8990}
9091
9192fn execute_oracle_update < F > (
0 commit comments