mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
plugins/pay: ensure htables are always tal objects.
We want to change the htable allocator to use tal, which will need this. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
94e8ce030a
commit
3c4ce9e448
1 changed files with 7 additions and 6 deletions
|
@ -425,11 +425,12 @@ static struct command_result *listsendpays_done(struct command *cmd,
|
|||
size_t i;
|
||||
const jsmntok_t *t, *arr;
|
||||
struct json_stream *ret;
|
||||
struct pay_map pay_map;
|
||||
struct pay_map *pay_map;
|
||||
struct pay_mpp *pm;
|
||||
struct pay_sort_key *order = tal_arr(tmpctx, struct pay_sort_key, 0);
|
||||
|
||||
pay_map_init(&pay_map);
|
||||
pay_map = tal(cmd, struct pay_map);
|
||||
pay_map_init(pay_map);
|
||||
|
||||
arr = json_get_member(buf, result, "payments");
|
||||
if (!arr || arr->type != JSMN_ARRAY)
|
||||
|
@ -474,7 +475,7 @@ static struct command_result *listsendpays_done(struct command *cmd,
|
|||
key.payment_hash = &payment_hash;
|
||||
key.groupid = groupid;
|
||||
|
||||
pm = pay_map_get(&pay_map, &key);
|
||||
pm = pay_map_get(pay_map, &key);
|
||||
if (!pm) {
|
||||
pm = tal(cmd, struct pay_mpp);
|
||||
pm->state = 0;
|
||||
|
@ -491,7 +492,7 @@ static struct command_result *listsendpays_done(struct command *cmd,
|
|||
pm->sortkey.payment_hash = pm->payment_hash;
|
||||
pm->sortkey.groupid = groupid;
|
||||
pm->success_at = UINT64_MAX;
|
||||
pay_map_add(&pay_map, pm);
|
||||
pay_map_add(pay_map, pm);
|
||||
// First time we see the groupid we add it to the order
|
||||
// array, so we can retrieve them in the correct order.
|
||||
tal_arr_expand(&order, pm->sortkey);
|
||||
|
@ -528,11 +529,11 @@ static struct command_result *listsendpays_done(struct command *cmd,
|
|||
ret = jsonrpc_stream_success(cmd);
|
||||
json_array_start(ret, "pays");
|
||||
for (i = 0; i < tal_count(order); i++) {
|
||||
pm = pay_map_get(&pay_map, &order[i]);
|
||||
pm = pay_map_get(pay_map, &order[i]);
|
||||
assert(pm != NULL);
|
||||
add_new_entry(ret, buf, pm);
|
||||
}
|
||||
pay_map_clear(&pay_map);
|
||||
pay_map_clear(pay_map);
|
||||
json_array_end(ret);
|
||||
return command_finished(cmd, ret);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue