Returns true and sets first_blocknum and number_of_blocks if * there's more to find. */
| 431 | /* Returns true and sets first_blocknum and number_of_blocks if |
| 432 | * there's more to find. */ |
| 433 | static bool next_block_range(struct seeker *seeker, |
| 434 | u32 prev_num_blocks, |
| 435 | u32 *first_blocknum, u32 *number_of_blocks) |
| 436 | { |
| 437 | const u32 current_height = seeker->daemon->current_blockheight; |
| 438 | |
| 439 | /* We always try to get twice as many as last time. */ |
| 440 | *number_of_blocks = prev_num_blocks * 2; |
| 441 | |
| 442 | if (seeker->scid_probe_start > 0) { |
| 443 | /* Enlarge probe to cover prior blocks, but twice as many. */ |
| 444 | if (*number_of_blocks > seeker->scid_probe_start) { |
| 445 | *number_of_blocks = seeker->scid_probe_start; |
| 446 | *first_blocknum = 0; |
| 447 | } else { |
| 448 | *first_blocknum |
| 449 | = seeker->scid_probe_start - *number_of_blocks; |
| 450 | } |
| 451 | seeker->scid_probe_start = *first_blocknum; |
| 452 | return true; |
| 453 | } |
| 454 | |
| 455 | /* We allow 6 new blocks since we started; they should be empty anyway */ |
| 456 | if (seeker->scid_probe_end + 6 < current_height) { |
| 457 | if (seeker->scid_probe_end + *number_of_blocks > current_height) |
| 458 | *number_of_blocks |
| 459 | = current_height - seeker->scid_probe_end; |
| 460 | *first_blocknum = seeker->scid_probe_end + 1; |
| 461 | seeker->scid_probe_end = *first_blocknum + *number_of_blocks - 1; |
| 462 | return true; |
| 463 | } |
| 464 | |
| 465 | /* No more to find. */ |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | static int cmp_scid(const struct short_channel_id *a, |
| 470 | const struct short_channel_id *b, |
no outgoing calls