@@ -119,6 +119,7 @@ access(all) contract FlowTransactionSchedulerUtils {
119119 access (all ) view fun getTransactionIDsByTimestamp (_ timestamp : UFix64 ): [UInt64 ]
120120 access (all ) fun getTransactionIDsByTimestampRange (startTimestamp : UFix64 , endTimestamp : UFix64 ): {UFix64 : [UInt64 ]}
121121 access (all ) view fun getTransactionStatus (id : UInt64 ): FlowTransactionScheduler .Status ?
122+ access (all ) view fun getSortedTimestamps (): FlowTransactionScheduler .SortedTimestamps
122123 }
123124
124125 /// Manager resource is meant to provide users and developers with a simple way
@@ -290,6 +291,7 @@ access(all) contract FlowTransactionSchedulerUtils {
290291 ids .remove (at : index ! )
291292 if ids .length == 0 {
292293 self .idsByTimestamp .remove (key : timestamp )
294+ self .sortedTimestamps .remove (timestamp : timestamp )
293295 } else {
294296 self .idsByTimestamp [timestamp ] = ids
295297 }
@@ -320,9 +322,14 @@ access(all) contract FlowTransactionSchedulerUtils {
320322 let ids = self .idsByTimestamp [timestamp ] ?? []
321323 for id in ids {
322324 let status = FlowTransactionScheduler .getStatus (id : id )
323- if status == nil || status == FlowTransactionScheduler .Status .Unknown {
324- transactionsToRemove .append (id )
325- }
325+ transactionsToRemove .append (id )
326+ }
327+ // Need to temporarily limit the number of transactions to remove
328+ // because some managers on mainnet have already hit the limit and we need to batch them
329+ // to make sure they get cleaned up properly
330+ // This will be removed eventually
331+ if transactionsToRemove .length > 100 {
332+ break
326333 }
327334 }
328335
@@ -541,6 +548,12 @@ access(all) contract FlowTransactionSchedulerUtils {
541548 }
542549 return FlowTransactionScheduler .Status .Unknown
543550 }
551+
552+ /// Gets the sorted timestamps struct
553+ /// @return: The sorted timestamps struct
554+ access (all ) view fun getSortedTimestamps (): FlowTransactionScheduler .SortedTimestamps {
555+ return self .sortedTimestamps
556+ }
544557 }
545558
546559 /// Create a new Manager instance
0 commit comments