| 1510 | }; |
| 1511 | |
| 1512 | static const char *init(struct command *init_cmd, |
| 1513 | const char *buf UNUSED, const jsmntok_t *config UNUSED) |
| 1514 | { |
| 1515 | struct plugin *plugin = init_cmd->plugin; |
| 1516 | struct askrene *askrene = get_askrene(plugin); |
| 1517 | |
| 1518 | askrene->plugin = plugin; |
| 1519 | askrene->layers = new_layer_name_hash(askrene); |
| 1520 | list_head_init(&askrene->children); |
| 1521 | list_head_init(&askrene->waiters); |
| 1522 | askrene->num_live_requests = 0; |
| 1523 | askrene->reserved = new_reserve_htable(askrene); |
| 1524 | askrene->gossmap = gossmap_load(askrene, GOSSIP_STORE_FILENAME, |
| 1525 | plugin_gossmap_logcb, plugin); |
| 1526 | |
| 1527 | if (!askrene->gossmap) |
| 1528 | plugin_err(plugin, "Could not load gossmap %s: %s", |
| 1529 | GOSSIP_STORE_FILENAME, strerror(errno)); |
| 1530 | askrene->capacities = get_capacities(askrene, askrene->plugin, askrene->gossmap); |
| 1531 | rpc_scan(init_cmd, "getinfo", take(json_out_obj(NULL, NULL, NULL)), |
| 1532 | "{id:%}", JSON_SCAN(json_to_node_id, &askrene->my_id)); |
| 1533 | |
| 1534 | plugin_set_data(plugin, askrene); |
| 1535 | |
| 1536 | load_layers(askrene, init_cmd); |
| 1537 | |
| 1538 | /* Layer needs its own command to write to the datastore */ |
| 1539 | askrene->layer_cmd = aux_command(init_cmd); |
| 1540 | return NULL; |
| 1541 | } |
| 1542 | |
| 1543 | int main(int argc, char *argv[]) |
| 1544 | { |
nothing calls this directly
no test coverage detected