瀏覽代碼

Use get_price_unsafe to simplify logic

Tom Pointon 3 年之前
父節點
當前提交
4770babd50
共有 1 個文件被更改,包括 2 次插入4 次删除
  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
     }