Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cadence/contracts/FlowYieldVaultsSchedulerRegistry.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ access(all) contract FlowYieldVaultsSchedulerRegistry {
return self.pendingQueue.keys
}

/// Check if a yield vault ID is in the pending queue - O(1) lookup
access(all) view fun isPending(yieldVaultID: UInt64): Bool {
return self.pendingQueue.containsKey(yieldVaultID)
}

/// Get paginated pending yield vault IDs
/// @param page: The page number (0-indexed)
/// @param size: The page size (defaults to MAX_BATCH_SIZE if nil)
Expand Down
4 changes: 1 addition & 3 deletions cadence/contracts/FlowYieldVaultsSchedulerV1.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ access(all) contract FlowYieldVaultsSchedulerV1 {
scanned = scanned + 1

// Skip if already in pending queue
// TODO: This is extremely inefficient - accessing from mapping is preferrable to iterating over
// an array
if FlowYieldVaultsSchedulerRegistry.getPendingYieldVaultIDs().contains(yieldVaultID) {
if FlowYieldVaultsSchedulerRegistry.isPending(yieldVaultID: yieldVaultID) {
continue
}

Expand Down
Loading