Browse Source

lightningd: rename 'daemons' to 'subdaemons'.

We're a daemon.  They're subdaemons.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
c33c971478
  1. 23
      lightningd/lightningd.c
  2. 2
      lightningd/lightningd.h
  3. 8
      lightningd/options.c

23
lightningd/lightningd.c

@ -87,7 +87,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
return ld; return ld;
} }
static const char *daemons[] = { static const char *subdaemons[] = {
"lightning_channeld", "lightning_channeld",
"lightning_closingd", "lightning_closingd",
"lightning_connectd", "lightning_connectd",
@ -98,12 +98,12 @@ static const char *daemons[] = {
}; };
/* Check we can run them, and check their versions */ /* Check we can run them, and check their versions */
void test_daemons(const struct lightningd *ld) void test_subdaemons(const struct lightningd *ld)
{ {
size_t i; size_t i;
for (i = 0; i < ARRAY_SIZE(daemons); i++) { for (i = 0; i < ARRAY_SIZE(subdaemons); i++) {
int outfd; int outfd;
const char *dpath = path_join(tmpctx, ld->daemon_dir, daemons[i]); const char *dpath = path_join(tmpctx, ld->daemon_dir, subdaemons[i]);
const char *verstring; const char *verstring;
pid_t pid = pipecmd(&outfd, NULL, &outfd, pid_t pid = pipecmd(&outfd, NULL, &outfd,
dpath, "--version", NULL); dpath, "--version", NULL);
@ -116,17 +116,18 @@ void test_daemons(const struct lightningd *ld)
err(1, "Could not get output from %s", dpath); err(1, "Could not get output from %s", dpath);
if (!strstarts(verstring, version()) if (!strstarts(verstring, version())
|| verstring[strlen(version())] != '\n') || verstring[strlen(version())] != '\n')
errx(1, "%s: bad version '%s'", daemons[i], verstring); errx(1, "%s: bad version '%s'",
subdaemons[i], verstring);
} }
} }
/* Check if all daemons exist in specified directory. */ /* Check if all subdaemons exist in specified directory. */
static bool has_all_daemons(const char* daemon_dir) static bool has_all_subdaemons(const char* daemon_dir)
{ {
size_t i; size_t i;
bool missing_daemon = false; bool missing_daemon = false;
for (i = 0; i < ARRAY_SIZE(daemons); ++i) { for (i = 0; i < ARRAY_SIZE(subdaemons); ++i) {
if (!path_is_file(path_join(tmpctx, daemon_dir, daemons[i]))) { if (!path_is_file(path_join(tmpctx, daemon_dir, subdaemons[i]))) {
missing_daemon = true; missing_daemon = true;
break; break;
} }
@ -189,7 +190,7 @@ static const char *find_my_pkglibexec_path(const tal_t *ctx,
static const char *find_daemon_dir(const tal_t *ctx, const char *argv0) static const char *find_daemon_dir(const tal_t *ctx, const char *argv0)
{ {
const char *my_path = find_my_path(ctx, argv0); const char *my_path = find_my_path(ctx, argv0);
if (has_all_daemons(my_path)) if (has_all_subdaemons(my_path))
return my_path; return my_path;
return find_my_pkglibexec_path(ctx, take(my_path)); return find_my_pkglibexec_path(ctx, take(my_path));
} }
@ -333,7 +334,7 @@ int main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
/* Make sure we can reach other daemons, and versions match. */ /* Make sure we can reach other daemons, and versions match. */
test_daemons(ld); test_subdaemons(ld);
/* Initialize wallet, now that we are in the correct directory */ /* Initialize wallet, now that we are in the correct directory */
ld->wallet = wallet_new(ld, ld->log, &ld->timers); ld->wallet = wallet_new(ld, ld->log, &ld->timers);

2
lightningd/lightningd.h

@ -207,7 +207,7 @@ struct lightningd {
const struct chainparams *get_chainparams(const struct lightningd *ld); const struct chainparams *get_chainparams(const struct lightningd *ld);
/* Check we can run subdaemons, and check their versions */ /* Check we can run subdaemons, and check their versions */
void test_daemons(const struct lightningd *ld); void test_subdaemons(const struct lightningd *ld);
/* Notify lightningd about new blocks. */ /* Notify lightningd about new blocks. */
void notify_new_block(struct lightningd *ld, u32 block_height); void notify_new_block(struct lightningd *ld, u32 block_height);

8
lightningd/options.c

@ -678,9 +678,9 @@ static void opt_parse_from_config(struct lightningd *ld)
tal_free(contents); tal_free(contents);
} }
static char *test_daemons_and_exit(struct lightningd *ld) static char *test_subdaemons_and_exit(struct lightningd *ld)
{ {
test_daemons(ld); test_subdaemons(ld);
exit(0); exit(0);
return NULL; return NULL;
} }
@ -705,7 +705,7 @@ void register_opts(struct lightningd *ld)
opt_register_early_noarg("--help|-h", opt_lightningd_usage, ld, opt_register_early_noarg("--help|-h", opt_lightningd_usage, ld,
"Print this message."); "Print this message.");
opt_register_early_noarg("--test-daemons-only", opt_register_early_noarg("--test-daemons-only",
test_daemons_and_exit, test_subdaemons_and_exit,
ld, opt_hidden); ld, opt_hidden);
opt_register_arg("--bitcoin-datadir", opt_set_talstr, NULL, opt_register_arg("--bitcoin-datadir", opt_set_talstr, NULL,
@ -885,7 +885,7 @@ static void add_config(struct lightningd *ld,
|| opt->cb == (void *)opt_set_testnet || opt->cb == (void *)opt_set_testnet
|| opt->cb == (void *)opt_set_mainnet || opt->cb == (void *)opt_set_mainnet
|| opt->cb == (void *)opt_lightningd_usage || opt->cb == (void *)opt_lightningd_usage
|| opt->cb == (void *)test_daemons_and_exit) { || opt->cb == (void *)test_subdaemons_and_exit) {
/* These are not important */ /* These are not important */
} else if (opt->cb == (void *)opt_set_bool) { } else if (opt->cb == (void *)opt_set_bool) {
const bool *b = opt->u.carg; const bool *b = opt->u.carg;

Loading…
Cancel
Save