Skip to content

Commit a30b42b

Browse files
committed
Use lazer/hermes message timestamps
1 parent 5f7f754 commit a30b42b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

apps/hip-3-pusher/src/pusher/hermes_listener.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import json
33
from loguru import logger
4-
import time
54
import websockets
65
from tenacity import retry, retry_if_exception_type, wait_fixed
76

@@ -86,7 +85,6 @@ def parse_hermes_message(self, data):
8685
expo = price_object["expo"]
8786
publish_time = price_object["publish_time"]
8887
logger.debug("Hermes update: {} {} {} {}", id, price, expo, publish_time)
89-
now = time.time()
90-
self.hermes_state.put(id, PriceUpdate(price, now))
88+
self.hermes_state.put(id, PriceUpdate(price, publish_time))
9189
except Exception as e:
9290
logger.error("parse_hermes_message error: {}", e)

apps/hip-3-pusher/src/pusher/lazer_listener.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import json
33
from loguru import logger
4-
import time
54
import websockets
65
from tenacity import retry, retry_if_exception_type, wait_fixed
76

@@ -88,14 +87,14 @@ def parse_lazer_message(self, data):
8887
if data.get("type", "") != "streamUpdated":
8988
return
9089
price_feeds = data["parsed"]["priceFeeds"]
91-
logger.debug("price_feeds: {}", price_feeds)
92-
now = time.time()
90+
timestamp = int(data["parsed"]["timestampUs"]) / 1_000_000.0
91+
logger.debug("price_feeds: {} timestamp: {}", price_feeds, timestamp)
9392
for feed_update in price_feeds:
9493
feed_id = feed_update.get("priceFeedId", None)
9594
price = feed_update.get("price", None)
9695
if feed_id is None or price is None:
9796
continue
9897
else:
99-
self.lazer_state.put(feed_id, PriceUpdate(price, now))
98+
self.lazer_state.put(feed_id, PriceUpdate(price, timestamp))
10099
except Exception as e:
101100
logger.error("parse_lazer_message error: {}", e)

0 commit comments

Comments
 (0)