Browse Source

Use get_price_unsafe to simplify logic

Tom Pointon 3 years ago
parent
commit
4770babd50
1 changed files with 2 additions and 4 deletions
  1. 2 4
      aptos/contracts/sources/pyth.move

+ 2 - 4
aptos/contracts/sources/pyth.move

@@ -154,8 +154,7 @@ module pyth::pyth {
                 break
             };
 
-            let price_feed = price_info::get_price_feed(&state::get_latest_price_info(*price_identifier));
-            let cached_timestamp = price::get_timestamp(&price_feed::get_price(price_feed));
+            let cached_timestamp = price::get_timestamp(&get_price_unsafe(*price_identifier));
             if (cached_timestamp < *vector::borrow(&publish_times, i)) {
                 fresh_data = true;
                 break
@@ -180,8 +179,7 @@ module pyth::pyth {
         if (!price_feed_exists(*price_identifier)) {
             return true
         };
-        let cached_timestamp = price::get_timestamp(
-            &price_feed::get_price(price_info::get_price_feed(&state::get_latest_price_info(*price_identifier))));
+        let cached_timestamp = price::get_timestamp(&get_price_unsafe(*price_identifier));
         
         update_timestamp > cached_timestamp
     }