| 221 | } |
| 222 | |
| 223 | void catchup() |
| 224 | { |
| 225 | if (current >= positions.upper()) { |
| 226 | // Stop the process if there is nothing left to catch-up. This |
| 227 | // also handles the case where the input interval is empty. |
| 228 | promise.set(Nothing()); |
| 229 | terminate(self()); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | // Store the future so that we can discard it if the user wants to |
| 234 | // cancel the catch-up operation. |
| 235 | catching = log::catchup(quorum, replica, network, proposal, current) |
| 236 | .onDiscarded(defer(self(), &Self::discarded)) |
| 237 | .onFailed(defer(self(), &Self::failed)) |
| 238 | .onReady(defer(self(), &Self::succeeded)); |
| 239 | |
| 240 | Clock::timer(timeout, lambda::bind(&Self::timedout, catching)); |
| 241 | } |
| 242 | |
| 243 | |
| 244 | void discarded() |