瀏覽代碼

Address comments

Ali Behjati 2 年之前
父節點
當前提交
3a1b2a36b3

+ 1 - 1
hermes/Cargo.lock

@@ -4120,7 +4120,7 @@ dependencies = [
 [[package]]
 name = "pyth-oracle"
 version = "2.21.0"
-source = "git+https://github.com/pyth-network/pyth-client?rev=319cdc1baade5c4780b830eaf927f9bfef89ee39#319cdc1baade5c4780b830eaf927f9bfef89ee39"
+source = "git+https://github.com/pyth-network/pyth-client?rev=1bdac0d2ee39a5a9f27eb86e4fd01229bd68aa5a#1bdac0d2ee39a5a9f27eb86e4fd01229bd68aa5a"
 dependencies = [
  "bindgen",
  "bytemuck",

+ 1 - 2
hermes/Cargo.toml

@@ -64,8 +64,7 @@ serde_qs = { version = "0.12.0", features = ["axum"] }
 
 serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1"}
 wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }
-# pyth-oracle = { git = "https://github.com/pyth-network/pyth-client", rev = "7d593d87e07a1e2486e7ca21597d664ee72be1ec", features = ["library"] }
-pyth-oracle = { git = "https://github.com/pyth-network/pyth-client", rev = "319cdc1baade5c4780b830eaf927f9bfef89ee39" , features = ["library"] }
+pyth-oracle = { git = "https://github.com/pyth-network/pyth-client", rev = "1bdac0d2ee39a5a9f27eb86e4fd01229bd68aa5a" , features = ["library", "strum", "serde"] }
 
 
 strum = { version = "0.24", features = ["derive"] }

+ 1 - 0
hermes/src/store/storage.rs

@@ -106,6 +106,7 @@ impl MessageState {
 }
 
 #[derive(Clone, Copy)]
+#[allow(dead_code)]
 pub enum MessageStateFilter {
     All,
     Only(MessageType),

+ 8 - 5
hermes/src/store/storage/local_storage.rs

@@ -4,6 +4,7 @@ use {
         MessageState,
         MessageStateFilter,
         MessageStateKey,
+        MessageStateTime,
         RequestTime,
         Storage,
         StorageInstance,
@@ -36,10 +37,7 @@ impl LocalStorage {
     pub fn new_instance(cache_size: u64) -> StorageInstance {
         Box::new(Self {
             message_cache: Arc::new(DashMap::new()),
-            accumulator_cache: Cache::builder()
-                .max_capacity(cache_size)
-                .time_to_live(std::time::Duration::from_secs(60 * 60 * 24))
-                .build(),
+            accumulator_cache: Cache::builder().max_capacity(cache_size).build(),
             cache_size,
         })
     }
@@ -62,12 +60,17 @@ impl LocalStorage {
                             }
                         }
 
+                        let lookup_time = MessageStateTime {
+                            publish_time: time,
+                            slot:         0,
+                        };
+
                         // Binary search returns Ok(idx) if the element is found at index idx or Err(idx) if it's not
                         // found which idx is the index where the element should be inserted to keep the vector sorted.
                         // Getting idx within any of the match arms will give us the index of the element that is
                         // closest after or equal to the requested time.
                         let idx = match key_cache
-                            .binary_search_by_key(&time, |record| record.time().publish_time)
+                            .binary_search_by_key(&lookup_time, |record| record.time())
                         {
                             Ok(idx) => idx,
                             Err(idx) => idx,

+ 0 - 7
hermes/src/store/types.rs

@@ -2,17 +2,10 @@ use {
     super::proof::wormhole_merkle::WormholeMerkleMessageProof,
     pyth_oracle::{
         Message,
-        MessageType,
         PriceFeedMessage,
     },
 };
 
-#[derive(Clone, PartialEq, Eq, Debug, Hash)]
-pub struct MessageIdentifier {
-    pub price_id: [u8; 32],
-    pub type_:    MessageType,
-}
-
 #[derive(Clone, PartialEq, Debug)]
 pub struct ProofSet {
     pub wormhole_merkle_proof: WormholeMerkleMessageProof,

+ 1 - 1
hermes/src/store/wormhole.rs

@@ -27,7 +27,7 @@ use {
     },
 };
 
-/// Parses and verifies a VAA to ensure it is signed by the Wormhole guardian set.
+/// Verifies a VAA to ensure it is signed by the Wormhole guardian set.
 pub async fn verify_vaa<'a>(
     store: &Store,
     vaa: Vaa<&'a RawMessage>,