From 11a7f011778a4f771f838cef4e8635a2e73cea25 Mon Sep 17 00:00:00 2001 From: Herman Slatman Date: Wed, 22 Dec 2021 15:42:49 +0100 Subject: [PATCH] Simplify lookup cursor logic for ExternalAccountKeys --- acme/db/nosql/account.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/acme/db/nosql/account.go b/acme/db/nosql/account.go index ca51e8ba..1a611ad2 100644 --- a/acme/db/nosql/account.go +++ b/acme/db/nosql/account.go @@ -282,13 +282,15 @@ func (db *DB) GetExternalAccountKeys(ctx context.Context, provisionerName, curso if dbeak.Provisioner != provisionerName { continue } - // skip the IDs not matching the cursor to look for in the sorted list. - if cursor != "" && !foundCursorKey && cursor != dbeak.ID { - continue - } - // look for the entry pointed to by the cursor (the next item to return), to start selecting items - if cursor != "" && !foundCursorKey && cursor == dbeak.ID { - foundCursorKey = true + // look for the entry pointed to by the cursor (the next item to return) and start selecting items after finding it + if cursor != "" && !foundCursorKey { + if cursor == dbeak.ID { + // from here on, items should be selected for the result. + foundCursorKey = true + } else { + // skip the IDs not matching the cursor to look for. + continue + } } // return if the limit of items was found in the previous iteration; the next cursor is set to the next item to return if len(keys) == limit {