Returns true and sets first_blocknum and number_of_blocks if * there's more to find. */
| 386 | /* Returns true and sets first_blocknum and number_of_blocks if |
| 387 | * there's more to find. */ |
| 388 | static bool next_block_range(struct seeker *seeker, |
| 389 | u32 prev_num_blocks, |
| 390 | u32 *first_blocknum, u32 *number_of_blocks) |
| 391 | { |
| 392 | const u32 current_height = seeker->daemon->current_blockheight; |
| 393 | |
| 394 | /* We always try to get twice as many as last time. */ |
| 395 | *number_of_blocks = prev_num_blocks * 2; |
| 396 | |
| 397 | if (seeker->scid_probe_start > 0) { |
| 398 | /* Enlarge probe to cover prior blocks, but twice as many. */ |
| 399 | if (*number_of_blocks > seeker->scid_probe_start) { |
| 400 | *number_of_blocks = seeker->scid_probe_start; |
| 401 | *first_blocknum = 0; |
| 402 | } else { |
| 403 | *first_blocknum |
| 404 | = seeker->scid_probe_start - *number_of_blocks; |
| 405 | } |
| 406 | seeker->scid_probe_start = *first_blocknum; |
| 407 | return true; |
| 408 | } |
| 409 | |
| 410 | /* We allow 6 new blocks since we started; they should be empty anyway */ |
| 411 | if (seeker->scid_probe_end + 6 < current_height) { |
| 412 | if (seeker->scid_probe_end + *number_of_blocks > current_height) |
| 413 | *number_of_blocks |
| 414 | = current_height - seeker->scid_probe_end; |
| 415 | *first_blocknum = seeker->scid_probe_end + 1; |
| 416 | seeker->scid_probe_end = *first_blocknum + *number_of_blocks - 1; |
| 417 | return true; |
| 418 | } |
| 419 | |
| 420 | /* No more to find. */ |
| 421 | return false; |
| 422 | } |
| 423 | |
| 424 | static int cmp_scid(const struct short_channel_id *a, |
| 425 | const struct short_channel_id *b, |
no outgoing calls