The logic looks mostly good to me, but do we really want to use 'delta' as an implicit success-counter here? In principle 'delta' could end up being 0 due to some TSC borkage, and we'd interpret that as "first success", which it clearly isn't.

The end result will still be a 'failure', but why not use a proper separate variable to count attempts and make the code easier to read and failure scenarios more predictable?