@@ -22,9 +22,7 @@ class PriceUpdate:
22
22
PUBLISHER_CACHE_MAX_LEN = 30
23
23
"""Roughly 30 mins of updates, since the check runs about once a minute"""
24
24
25
- PUBLISHER_CACHE : Dict [tuple [str , str ], List [PriceUpdate ]] = defaultdict (
26
- lambda : deque (maxlen = PUBLISHER_CACHE_MAX_LEN )
27
- )
25
+ PUBLISHER_CACHE = defaultdict (lambda : deque (maxlen = PUBLISHER_CACHE_MAX_LEN ))
28
26
"""
29
27
Cache that holds tuples of (price, timestamp) for publisher/feed combos as they stream in.
30
28
Entries longer than `PUBLISHER_CACHE_MAX_LEN` are automatically pruned.
@@ -54,13 +52,17 @@ class PublisherState:
54
52
55
53
@runtime_checkable
56
54
class PublisherCheck (Protocol ):
57
- def __init__ (self , state : PublisherState , config : PublisherCheckConfig ): ...
55
+ def __init__ (self , state : PublisherState , config : PublisherCheckConfig ):
56
+ ...
58
57
59
- def state (self ) -> PublisherState : ...
58
+ def state (self ) -> PublisherState :
59
+ ...
60
60
61
- def run (self ) -> bool : ...
61
+ def run (self ) -> bool :
62
+ ...
62
63
63
- def error_message (self ) -> dict : ...
64
+ def error_message (self ) -> dict :
65
+ ...
64
66
65
67
66
68
class PublisherWithinAggregateConfidenceCheck (PublisherCheck ):
@@ -256,19 +258,15 @@ def __init__(self, state: PublisherState, config: PublisherCheckConfig):
256
258
self .__max_slot_distance : int = int (config ["max_slot_distance" ])
257
259
258
260
from pyth_observer .check .stall_detection import (
259
- StallDetectionResult ,
260
261
StallDetector ,
261
262
) # noqa: deferred import to avoid circular import
262
263
263
264
self .__detector = StallDetector (
264
265
stall_time_limit = self .__stall_time_limit ,
265
- noise_threshold = float (config . get ( "noise_threshold" ) ),
266
- min_noise_samples = int (config . get ( "min_noise_samples" ) ),
266
+ noise_threshold = float (config [ "noise_threshold" ] ),
267
+ min_noise_samples = int (config [ "min_noise_samples" ] ),
267
268
)
268
269
269
- # Keep track of last analysis for error reporting
270
- self .__last_analysis : Optional [StallDetectionResult ] = None
271
-
272
270
def state (self ) -> PublisherState :
273
271
return self .__state
274
272
@@ -297,7 +295,7 @@ def run(self) -> bool:
297
295
publisher_key = (self .__state .publisher_name , self .__state .symbol )
298
296
PUBLISHER_CACHE [publisher_key ].append (
299
297
PriceUpdate (current_time , self .__state .price )
300
- ),
298
+ )
301
299
updates = PUBLISHER_CACHE [publisher_key ]
302
300
303
301
# Analyze for stalls
0 commit comments