daemon: test restarting.

We add a "dev-restart" command which causes the daemon to close fds
and exec itself.  Then we do it after every command, with the caveat
that we always send a commit before newhtlc, because if not committed,
that is forgotten.  Fulfillhtlc and failhtlc get resent, since they're
idempotent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-08-18 14:25:14 +09:30
parent 5f368f1c95
commit 190b30e958
9 changed files with 178 additions and 9 deletions

View File

@@ -77,3 +77,22 @@ void opt_show_time(char buf[OPT_SHOW_LEN], const struct timerel *t)
} else
sprintf(buf, "%lus", t->ts.tv_sec);
}
char *opt_set_timeabs(const char *arg, struct timeabs *t)
{
long double d;
if (sscanf(arg, "%Lf", &d) != 1)
return tal_fmt(NULL, "'%s' is not a time", arg);
t->ts.tv_sec = d;
t->ts.tv_nsec = (d - t->ts.tv_sec) * 1000000000;
return NULL;
}
void opt_show_timeabs(char buf[OPT_SHOW_LEN], const struct timeabs *t)
{
long double d = t->ts.tv_sec;
d = d * 1000000000 + t->ts.tv_nsec;
sprintf(buf, "%.9Lf", d);
}