| 1579 | }; |
| 1580 | |
| 1581 | static const char *init(struct command *init_cmd, |
| 1582 | const char *buf UNUSED, const jsmntok_t *config UNUSED) |
| 1583 | { |
| 1584 | struct plugin *plugin = init_cmd->plugin; |
| 1585 | struct askrene *askrene = get_askrene(plugin); |
| 1586 | |
| 1587 | askrene->plugin = plugin; |
| 1588 | askrene->layers = new_layer_name_hash(askrene); |
| 1589 | list_head_init(&askrene->children); |
| 1590 | list_head_init(&askrene->waiters); |
| 1591 | askrene->num_live_requests = 0; |
| 1592 | askrene->reserved = new_reserve_htable(askrene); |
| 1593 | askrene->gossmap = gossmap_load(askrene, GOSSIP_STORE_FILENAME, |
| 1594 | plugin_gossmap_logcb, plugin); |
| 1595 | |
| 1596 | if (!askrene->gossmap) |
| 1597 | plugin_err(plugin, "Could not load gossmap %s: %s", |
| 1598 | GOSSIP_STORE_FILENAME, strerror(errno)); |
| 1599 | askrene->capacities = get_capacities(askrene, askrene->plugin, askrene->gossmap); |
| 1600 | rpc_scan(init_cmd, "getinfo", take(json_out_obj(NULL, NULL, NULL)), |
| 1601 | "{id:%}", JSON_SCAN(json_to_node_id, &askrene->my_id)); |
| 1602 | |
| 1603 | plugin_set_data(plugin, askrene); |
| 1604 | |
| 1605 | load_layers(askrene, init_cmd); |
| 1606 | |
| 1607 | /* Layer needs its own command to write to the datastore */ |
| 1608 | askrene->layer_cmd = aux_command(init_cmd); |
| 1609 | return NULL; |
| 1610 | } |
| 1611 | |
| 1612 | int main(int argc, char *argv[]) |
| 1613 | { |
nothing calls this directly
no test coverage detected