| 995 | static void retry_check_chain(struct chain_topology *topo); |
| 996 | |
| 997 | static void |
| 998 | check_chain(struct bitcoind *bitcoind, const char *chain, |
| 999 | const u32 headercount, const u32 blockcount, const bool ibd, |
| 1000 | const bool first_call, struct chain_topology *topo) |
| 1001 | { |
| 1002 | if (!streq(chain, chainparams->bip70_name)) |
| 1003 | fatal("Wrong network! Our Bitcoin backend is running on '%s'," |
| 1004 | " but we expect '%s'.", chain, chainparams->bip70_name); |
| 1005 | |
| 1006 | topo->headercount = headercount; |
| 1007 | |
| 1008 | if (first_call) { |
| 1009 | /* Has the Bitcoin backend gone backward ? */ |
| 1010 | check_blockcount(topo, blockcount); |
| 1011 | /* Get up to speed with topology. */ |
| 1012 | bitcoind_getrawblockbyheight(topo->bitcoind, topo->max_blockheight, |
| 1013 | init_topo, topo); |
| 1014 | } |
| 1015 | |
| 1016 | if (ibd) { |
| 1017 | if (first_call) |
| 1018 | log_unusual(bitcoind->log, |
| 1019 | "Waiting for initial block download (this can take" |
| 1020 | " a while!)"); |
| 1021 | else |
| 1022 | log_debug(bitcoind->log, |
| 1023 | "Still waiting for initial block download"); |
| 1024 | } else if (headercount != blockcount) { |
| 1025 | if (first_call) |
| 1026 | log_unusual(bitcoind->log, |
| 1027 | "Waiting for bitcoind to catch up" |
| 1028 | " (%u blocks of %u)", |
| 1029 | blockcount, headercount); |
| 1030 | else |
| 1031 | log_debug(bitcoind->log, |
| 1032 | "Waiting for bitcoind to catch up" |
| 1033 | " (%u blocks of %u)", |
| 1034 | blockcount, headercount); |
| 1035 | } else { |
| 1036 | if (!first_call) |
| 1037 | log_unusual(bitcoind->log, |
| 1038 | "Bitcoin backend now synced."); |
| 1039 | bitcoind->synced = true; |
| 1040 | return; |
| 1041 | } |
| 1042 | |
| 1043 | assert(!bitcoind->checkchain_timer); |
| 1044 | bitcoind->checkchain_timer |
| 1045 | = new_reltimer(bitcoind->ld->timers, bitcoind, |
| 1046 | /* Be 4x more aggressive in this case. */ |
| 1047 | time_divide(time_from_sec(bitcoind->ld->topology |
| 1048 | ->poll_seconds), 4), |
| 1049 | retry_check_chain, bitcoind->ld->topology); |
| 1050 | } |
| 1051 | |
| 1052 | static void retry_check_chain(struct chain_topology *topo) |
| 1053 | { |
nothing calls this directly
no test coverage detected