Browse Source

plugins/pay: iterate the htable properly, not from start each time.

time lightning-cli -R --network=regtest --lightning-dir /tmp/ltests-k8jhvtty/test_pay_stress_1/lightning-1/ listpays > /dev/null

Before:
	real	0m12.447s
	user	0m0.143s
	sys	0m0.008s

After:
	real	0m2.054s
	user	0m0.114s
	sys	0m0.024s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
4ba3797923
  1. 7
      plugins/pay.c

7
plugins/pay.c

@ -1858,10 +1858,11 @@ static struct command_result *listsendpays_done(struct command *cmd,
}
}
/* Now we've collapsed them, provide summary (free mem as we go). */
while ((pm = pay_map_first(&pay_map, &it)) != NULL) {
/* Now we've collapsed them, provide summary. */
for (pm = pay_map_first(&pay_map, &it);
pm;
pm = pay_map_next(&pay_map, &it)) {
add_new_entry(ret, buf, pm);
pay_map_del(&pay_map, pm);
}
pay_map_clear(&pay_map);

Loading…
Cancel
Save