@@ -131,14 +131,14 @@ abstract contract Scheduler is IScheduler, SchedulerState {
131131 }
132132
133133 // Clear price updates for removed price IDs before updating params
134- bool priceIdsChanged = _clearRemovedPriceUpdates (
134+ bool newPriceIdsAdded = _clearRemovedPriceUpdates (
135135 subscriptionId,
136136 currentParams.priceIds,
137137 newParams.priceIds
138138 );
139139
140- // Reset priceLastUpdatedAt to 0 if price IDs have changed
141- if (priceIdsChanged ) {
140+ // Reset priceLastUpdatedAt to 0 if new price IDs were added
141+ if (newPriceIdsAdded ) {
142142 _state.subscriptionStatuses[subscriptionId].priceLastUpdatedAt = 0 ;
143143 }
144144
@@ -216,18 +216,13 @@ abstract contract Scheduler is IScheduler, SchedulerState {
216216 * @param subscriptionId The ID of the subscription being updated.
217217 * @param currentPriceIds The array of price IDs currently associated with the subscription.
218218 * @param newPriceIds The new array of price IDs for the subscription.
219- * @return priceIdsChanged True if the price IDs list has changed (additions or removals) , false otherwise.
219+ * @return newPriceIdsAdded True if any new price IDs were added , false otherwise.
220220 */
221221 function _clearRemovedPriceUpdates (
222222 uint256 subscriptionId ,
223223 bytes32 [] storage currentPriceIds ,
224224 bytes32 [] memory newPriceIds
225- ) internal returns (bool priceIdsChanged ) {
226- // Check if the arrays have different lengths, which means the price IDs have changed
227- if (currentPriceIds.length != newPriceIds.length ) {
228- priceIdsChanged = true ;
229- }
230-
225+ ) internal returns (bool newPriceIdsAdded ) {
231226 // Iterate through old price IDs
232227 for (uint i = 0 ; i < currentPriceIds.length ; i++ ) {
233228 bytes32 oldPriceId = currentPriceIds[i];
@@ -244,33 +239,30 @@ abstract contract Scheduler is IScheduler, SchedulerState {
244239 // If not found in the new list, delete its stored update data
245240 if (! found) {
246241 delete _state.priceUpdates[subscriptionId][oldPriceId];
247- priceIdsChanged = true ;
248242 }
249243 }
250244
251245 // Check if any new price IDs were added
252- if (! priceIdsChanged) {
253- for (uint i = 0 ; i < newPriceIds.length ; i++ ) {
254- bytes32 newPriceId = newPriceIds[i];
255- bool found = false ;
256-
257- // Check if the new price ID exists in the current list
258- for (uint j = 0 ; j < currentPriceIds.length ; j++ ) {
259- if (currentPriceIds[j] == newPriceId) {
260- found = true ;
261- break ;
262- }
263- }
246+ for (uint i = 0 ; i < newPriceIds.length ; i++ ) {
247+ bytes32 newPriceId = newPriceIds[i];
248+ bool found = false ;
264249
265- // If a new price ID was added, mark as changed
266- if (! found) {
267- priceIdsChanged = true ;
250+ // Check if the new price ID exists in the current list
251+ for (uint j = 0 ; j < currentPriceIds.length ; j++ ) {
252+ if (currentPriceIds[j] == newPriceId) {
253+ found = true ;
268254 break ;
269255 }
270256 }
257+
258+ // If a new price ID was added, mark as changed
259+ if (! found) {
260+ newPriceIdsAdded = true ;
261+ break ;
262+ }
271263 }
272264
273- return priceIdsChanged ;
265+ return newPriceIdsAdded ;
274266 }
275267
276268 function updatePriceFeeds (
0 commit comments