@@ -208,10 +208,10 @@ abstract contract Pyth is
208208        if  (k <  context.priceIds.length  &&  context.priceFeeds[k].id ==  0 ) {
209209            uint  publishTime =  uint (priceInfo.publishTime);
210210            if  (
211-                 publishTime >=  context.config.minPublishTime  && 
212-                 publishTime <=  context.config.maxPublishTime  && 
213-                 (! context.config. checkUniqueness || 
214-                     context.config.minPublishTime  >  prevPublishTime)
211+                 publishTime >=  context.minAllowedPublishTime  && 
212+                 publishTime <=  context.maxAllowedPublishTime  && 
213+                 (! context.checkUniqueness || 
214+                     context.minAllowedPublishTime  >  prevPublishTime)
215215            ) {
216216                context.priceFeeds[k].id =  priceId;
217217                context.priceFeeds[k].price.price =  priceInfo.price;
@@ -231,7 +231,7 @@ abstract contract Pyth is
231231    function _processSingleUpdateDataBlob  (
232232        bytes  calldata  singleUpdateData ,
233233        PythInternalStructs.UpdateParseContext memory  context 
234-     ) internal  view  {
234+     ) internal  view  returns  ( uint64   numUpdates )  {
235235        // Check magic number and length first 
236236        if  (
237237            singleUpdateData.length  <=  4  || 
@@ -281,12 +281,18 @@ abstract contract Pyth is
281281        if  (offset !=  encoded.length ) {
282282            revert  PythErrors.InvalidUpdateData ();
283283        }
284+ 
285+         // Return the number of updates in this blob for tracking 
286+         return  merkleData.numUpdates;
284287    }
285288
286289    function parsePriceFeedUpdatesInternal  (
287290        bytes [] calldata  updateData ,
288291        bytes32 [] calldata  priceIds ,
289-         PythInternalStructs.ParseConfig memory  config 
292+         uint64  minAllowedPublishTime ,
293+         uint64  maxAllowedPublishTime ,
294+         bool  checkUniqueness ,
295+         bool  checkUpdateDataIsMinimal 
290296    )
291297        internal 
292298        returns  (
@@ -299,39 +305,38 @@ abstract contract Pyth is
299305            if  (msg .value  <  requiredFee) revert  PythErrors.InsufficientFee ();
300306        }
301307
302-         // In minimal update data mode, revert if we have more or less updates than price IDs 
303-         if  (config.checkUpdateDataIsMinimal) {
304-             uint64  totalUpdatesAcrossBlobs =  0 ;
305-             for  (uint  i =  0 ; i <  updateData.length ; i++ ) {
306-                 (uint  offset , ) =  extractUpdateTypeFromAccumulatorHeader (
307-                     updateData[i]
308-                 );
309- 
310-                 totalUpdatesAcrossBlobs +=  parseWormholeMerkleHeaderNumUpdates (
311-                     updateData[i],
312-                     offset
313-                 );
314-             }
315-             if  (totalUpdatesAcrossBlobs !=  priceIds.length ) {
316-                 revert  PythErrors.InvalidArgument ();
317-             }
318-         }
319- 
320308        // Create the context struct that holds all shared parameters 
321309        PythInternalStructs.UpdateParseContext memory  context;
322310        context.priceIds =  priceIds;
323-         context.config =  config;
311+         context.minAllowedPublishTime =  minAllowedPublishTime;
312+         context.maxAllowedPublishTime =  maxAllowedPublishTime;
313+         context.checkUniqueness =  checkUniqueness;
314+         context.checkUpdateDataIsMinimal =  checkUpdateDataIsMinimal;
324315        context.priceFeeds =  new  PythStructs.PriceFeed [](priceIds.length );
325316        context.slots =  new  uint64 [](priceIds.length );
326317
318+         // Track total updates for minimal update data check 
319+         uint64  totalUpdatesAcrossBlobs =  0 ;
320+ 
327321        unchecked  {
328322            // Process each update, passing the context struct 
329323            // Parsed results will be filled in context.priceFeeds and context.slots 
330324            for  (uint  i =  0 ; i <  updateData.length ; i++ ) {
331-                 _processSingleUpdateDataBlob (updateData[i], context);
325+                 totalUpdatesAcrossBlobs +=  _processSingleUpdateDataBlob (
326+                     updateData[i],
327+                     context
328+                 );
332329            }
333330        }
334331
332+         // In minimal update data mode, revert if we have more or less updates than price IDs 
333+         if  (
334+             checkUpdateDataIsMinimal && 
335+             totalUpdatesAcrossBlobs !=  priceIds.length 
336+         ) {
337+             revert  PythErrors.InvalidArgument ();
338+         }
339+ 
335340        // Check all price feeds were found 
336341        for  (uint  k =  0 ; k <  priceIds.length ; k++ ) {
337342            if  (context.priceFeeds[k].id ==  0 ) {
@@ -356,12 +361,10 @@ abstract contract Pyth is
356361        (priceFeeds, ) =  parsePriceFeedUpdatesInternal (
357362            updateData,
358363            priceIds,
359-             PythInternalStructs.ParseConfig (
360-                 minPublishTime,
361-                 maxPublishTime,
362-                 false ,
363-                 false 
364-             )
364+             minPublishTime,
365+             maxPublishTime,
366+             false ,
367+             false 
365368        );
366369    }
367370
@@ -383,12 +386,10 @@ abstract contract Pyth is
383386            parsePriceFeedUpdatesInternal (
384387                updateData,
385388                priceIds,
386-                 PythInternalStructs.ParseConfig (
387-                     minPublishTime,
388-                     maxPublishTime,
389-                     false ,
390-                     true 
391-                 )
389+                 minPublishTime,
390+                 maxPublishTime,
391+                 false ,
392+                 true 
392393            );
393394    }
394395
@@ -567,12 +568,10 @@ abstract contract Pyth is
567568        (priceFeeds, ) =  parsePriceFeedUpdatesInternal (
568569            updateData,
569570            priceIds,
570-             PythInternalStructs.ParseConfig (
571-                 minPublishTime,
572-                 maxPublishTime,
573-                 true ,
574-                 false 
575-             )
571+             minPublishTime,
572+             maxPublishTime,
573+             true ,
574+             false 
576575        );
577576    }
578577
0 commit comments