@@ -146,6 +146,7 @@ export class Listener implements PriceStore {
146146 private promClient : PromClient | undefined ;
147147 private spyServiceHost : string ;
148148 private filters : FilterEntry [ ] = [ ] ;
149+ private ignorePricesOlderThanSecs : number ;
149150 private spyConnectionTime : TimestampInSec | undefined ;
150151 private readinessConfig : ListenerReadinessConfig ;
151152 private updateCallbacks : ( ( priceInfo : PriceInfo ) => any ) [ ] ;
@@ -156,6 +157,8 @@ export class Listener implements PriceStore {
156157 this . promClient = promClient ;
157158 this . spyServiceHost = config . spyServiceHost ;
158159 this . loadFilters ( config . filtersRaw ) ;
160+ // Don't store any prices received from wormhole that are over 1 hour old.
161+ this . ignorePricesOlderThanSecs = 60 * 60 ;
159162 this . readinessConfig = config . readiness ;
160163 this . updateCallbacks = [ ] ;
161164 this . observedVaas = new LRUCache ( {
@@ -216,7 +219,7 @@ export class Listener implements PriceStore {
216219 this . processVaa ( vaaBytes ) ;
217220 } ) ;
218221
219- this . spyConnectionTime = new Date ( ) . getTime ( ) / 1000 ;
222+ this . spyConnectionTime = this . currentTimeInSeconds ( ) ;
220223
221224 let connected = true ;
222225 stream ! . on ( "error" , ( err : any ) => {
@@ -252,6 +255,16 @@ export class Listener implements PriceStore {
252255 cachedInfo : PriceInfo | undefined ,
253256 observedInfo : PriceInfo
254257 ) : 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+
255268 if ( cachedInfo === undefined ) {
256269 return true ;
257270 }
@@ -379,4 +392,8 @@ export class Listener implements PriceStore {
379392
380393 return true ;
381394 }
395+
396+ private currentTimeInSeconds ( ) : number {
397+ return new Date ( ) . getTime ( ) / 1000 ;
398+ }
382399}
0 commit comments