@@ -146,6 +146,7 @@ export class Listener implements PriceStore {
146
146
private promClient : PromClient | undefined ;
147
147
private spyServiceHost : string ;
148
148
private filters : FilterEntry [ ] = [ ] ;
149
+ private ignorePricesOlderThanSecs : number ;
149
150
private spyConnectionTime : TimestampInSec | undefined ;
150
151
private readinessConfig : ListenerReadinessConfig ;
151
152
private updateCallbacks : ( ( priceInfo : PriceInfo ) => any ) [ ] ;
@@ -156,6 +157,8 @@ export class Listener implements PriceStore {
156
157
this . promClient = promClient ;
157
158
this . spyServiceHost = config . spyServiceHost ;
158
159
this . loadFilters ( config . filtersRaw ) ;
160
+ // Don't store any prices received from wormhole that are over 1 hour old.
161
+ this . ignorePricesOlderThanSecs = 60 * 60 ;
159
162
this . readinessConfig = config . readiness ;
160
163
this . updateCallbacks = [ ] ;
161
164
this . observedVaas = new LRUCache ( {
@@ -216,7 +219,7 @@ export class Listener implements PriceStore {
216
219
this . processVaa ( vaaBytes ) ;
217
220
} ) ;
218
221
219
- this . spyConnectionTime = new Date ( ) . getTime ( ) / 1000 ;
222
+ this . spyConnectionTime = this . currentTimeInSeconds ( ) ;
220
223
221
224
let connected = true ;
222
225
stream ! . on ( "error" , ( err : any ) => {
@@ -252,6 +255,16 @@ export class Listener implements PriceStore {
252
255
cachedInfo : PriceInfo | undefined ,
253
256
observedInfo : PriceInfo
254
257
) : boolean {
258
+ // Sometimes we get old VAAs from wormhole (for unknown reasons). These VAAs can include price feeds that
259
+ // were deleted and haven't been updated in a long time. This check filters out such feeds so they don't trigger
260
+ // the stale feeds check.
261
+ if (
262
+ observedInfo . attestationTime <
263
+ this . currentTimeInSeconds ( ) - this . ignorePricesOlderThanSecs
264
+ ) {
265
+ return false ;
266
+ }
267
+
255
268
if ( cachedInfo === undefined ) {
256
269
return true ;
257
270
}
@@ -379,4 +392,8 @@ export class Listener implements PriceStore {
379
392
380
393
return true ;
381
394
}
395
+
396
+ private currentTimeInSeconds ( ) : number {
397
+ return new Date ( ) . getTime ( ) / 1000 ;
398
+ }
382
399
}
0 commit comments