Browse Source

[price-service] Hotfix cache (#508)

Ali Behjati 2 years ago
parent
commit
59b0efbf6c
3 changed files with 10 additions and 5 deletions
  1. 2 2
      price-service/package-lock.json
  2. 1 1
      price-service/package.json
  3. 7 2
      price-service/src/listen.ts

+ 2 - 2
price-service/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "@pythnetwork/pyth-price-service",
-  "version": "2.3.2",
+  "version": "2.3.3",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "@pythnetwork/pyth-price-service",
-      "version": "2.3.2",
+      "version": "2.3.3",
       "license": "Apache-2.0",
       "dependencies": {
         "@certusone/wormhole-sdk": "^0.9.9",

+ 1 - 1
price-service/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@pythnetwork/pyth-price-service",
-  "version": "2.3.2",
+  "version": "2.3.3",
   "description": "Pyth Price Service",
   "main": "index.js",
   "scripts": {

+ 7 - 2
price-service/src/listen.ts

@@ -114,8 +114,13 @@ export class VaaCache {
 
   async removeExpiredValues() {
     const now = Math.floor(Date.now() / 1000);
-    for (const arr of this.cache.values()) {
-      arr.filter((vaaConf) => now - vaaConf.publishTime < this.ttl);
+    for (const key of this.cache.keys()) {
+      this.cache.set(
+        key,
+        this.cache
+          .get(key)!
+          .filter((vaaConf) => now - vaaConf.publishTime < this.ttl)
+      );
     }
   }
 }