| 244 | } |
| 245 | |
| 246 | static const char *init(struct command *init_cmd, |
| 247 | const char *buf UNUSED, |
| 248 | const jsmntok_t *config UNUSED) |
| 249 | { |
| 250 | plugin = init_cmd->plugin; |
| 251 | plugin_log(plugin, LOG_DBG, "Recover Plugin Initialised!"); |
| 252 | recovery = false; |
| 253 | lost_state_timer = global_timer(plugin, time_from_sec(STARTUP_TIME), |
| 254 | do_check_lost_peer, NULL); |
| 255 | u32 num_peers; |
| 256 | |
| 257 | /* Find number of peers */ |
| 258 | rpc_scan(init_cmd, "getinfo", |
| 259 | take(json_out_obj(NULL, NULL, NULL)), |
| 260 | "{id:%,num_peers:%}", |
| 261 | JSON_SCAN(json_to_node_id, &local_id), |
| 262 | JSON_SCAN(json_to_u32, &num_peers)); |
| 263 | |
| 264 | global_gossmap = notleak_with_children(gossmap_load(NULL, |
| 265 | GOSSIP_STORE_FILENAME, |
| 266 | plugin_gossmap_logcb, |
| 267 | plugin)); |
| 268 | |
| 269 | if (!global_gossmap) |
| 270 | plugin_err(plugin, "Could not load gossmap %s: %s", |
| 271 | GOSSIP_STORE_FILENAME, strerror(errno)); |
| 272 | |
| 273 | plugin_log(plugin, LOG_DBG, "Gossmap loaded!"); |
| 274 | |
| 275 | already_has_peers = num_peers > 1 ? 1: 0; |
| 276 | |
| 277 | return NULL; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | int main(int argc, char *argv[]) |
nothing calls this directly
no test coverage detected