Browse Source

options: Add --autocleaninvoice-* options.

ppa-0.6.1
ZmnSCPxj 7 years ago
committed by Christian Decker
parent
commit
5737853123
  1. 7
      lightningd/lightningd.c
  2. 4
      lightningd/lightningd.h
  3. 29
      lightningd/options.c
  4. 5
      lightningd/test/run-find_my_path.c

7
lightningd/lightningd.c

@ -76,6 +76,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->debug_subdaemon_io = NULL;
ld->daemon = false;
ld->pidfile = NULL;
ld->ini_autocleaninvoice_cycle = 0;
ld->ini_autocleaninvoice_expiredby = 86400;
return ld;
}
@ -337,6 +339,11 @@ int main(int argc, char *argv[])
fatal("Could not load invoices from the database");
}
/* Set up invoice autoclean. */
wallet_invoice_autoclean(ld->wallet,
ld->ini_autocleaninvoice_cycle,
ld->ini_autocleaninvoice_expiredby);
/* Set up gossip daemon. */
gossip_init(ld);

4
lightningd/lightningd.h

@ -153,6 +153,10 @@ struct lightningd {
/* Disable automatic reconnects */
bool no_reconnect;
/* Initial autocleaninvoice settings. */
u64 ini_autocleaninvoice_cycle;
u64 ini_autocleaninvoice_expiredby;
#if DEVELOPER
/* If we want to debug a subdaemon. */
const char *dev_debug_subdaemon;

29
lightningd/options.c

@ -66,6 +66,23 @@ static void tal_freefn(void *ptr)
#define TIME_FROM_MSEC(msec) \
{ { .tv_nsec = ((msec) % 1000) * 1000000, .tv_sec = (msec) / 1000 } }
static char *opt_set_u64(const char *arg, u64 *u)
{
char *endp;
unsigned long long l;
assert(arg != NULL);
/* This is how the manpage says to do it. Yech. */
errno = 0;
l = strtoull(arg, &endp, 0);
if (*endp || !arg[0])
return tal_fmt(NULL, "'%s' is not a number", arg);
*u = l;
if (errno || *u != l)
return tal_fmt(NULL, "'%s' is out of range", arg);
return NULL;
}
static char *opt_set_u32(const char *arg, u32 *u)
{
char *endp;
@ -137,6 +154,10 @@ static char *opt_add_ipaddr(const char *arg, struct lightningd *ld)
}
static void opt_show_u64(char buf[OPT_SHOW_LEN], const u64 *u)
{
snprintf(buf, OPT_SHOW_LEN, "%"PRIu64, *u);
}
static void opt_show_u32(char buf[OPT_SHOW_LEN], const u32 *u)
{
snprintf(buf, OPT_SHOW_LEN, "%"PRIu32, *u);
@ -307,6 +328,14 @@ static void config_register_opts(struct lightningd *ld)
opt_register_arg("--debug-subdaemon-io",
opt_set_charp, NULL, &ld->debug_subdaemon_io,
"Enable full peer IO logging in subdaemons ending in this string (can also send SIGUSR1 to toggle)");
opt_register_arg("--autocleaninvoice-cycle",
opt_set_u64, opt_show_u64,
&ld->ini_autocleaninvoice_cycle,
"Perform cleanup of expired invoices every given seconds, or do not autoclean if 0");
opt_register_arg("--autocleaninvoice-expired-by",
opt_set_u64, opt_show_u64,
&ld->ini_autocleaninvoice_cycle,
"If expired invoice autoclean enabled, invoices that have expired for at least this given seconds are cleaned");
}
#if DEVELOPER

5
lightningd/test/run-find_my_path.c

@ -110,6 +110,11 @@ bool wallet_htlcs_reconnect(struct wallet *wallet UNNEEDED,
struct htlc_in_map *htlcs_in UNNEEDED,
struct htlc_out_map *htlcs_out UNNEEDED)
{ fprintf(stderr, "wallet_htlcs_reconnect called!\n"); abort(); }
/* Generated stub for wallet_invoice_autoclean */
void wallet_invoice_autoclean(struct wallet * wallet UNNEEDED,
u64 cycle_seconds UNNEEDED,
u64 expired_by UNNEEDED)
{ fprintf(stderr, "wallet_invoice_autoclean called!\n"); abort(); }
/* Generated stub for wallet_invoice_load */
bool wallet_invoice_load(struct wallet *wallet UNNEEDED)
{ fprintf(stderr, "wallet_invoice_load called!\n"); abort(); }

Loading…
Cancel
Save