Skip to content

Commit

Permalink
Rename subdaemons, move them into top level.
Browse files Browse the repository at this point in the history
We leave the *build* results in lightningd/ for ease of in-place testing though.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Aug 29, 2017
1 parent 739b163 commit bbed5e3
Show file tree
Hide file tree
Showing 62 changed files with 330 additions and 304 deletions.
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
TAGS
ccan/tools/configurator/configurator
ccan/ccan/cdump/tools/cdump-enumstr
libsecp256k1.a
libsecp256k1.la
libsodium.a
libsodium.la
libwallycore.a
libwallycore.la
gen_*
lightning-cli/lightning-cli
cli/lightning-cli
tools/check-bolt
coverage
ccan/config.h
Expand All @@ -34,4 +28,3 @@ daemon/test/run-maxfee
test/test_protocol
test/test_sphinx
test/test_irc
lightningd/lightningd_closing
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ make
Running lightning:
```
bitcoind &
./lightningd/lightningd &
./daemon/lightning-cli help
./lightningd &
./cli/lightning-cli help
```
**Note**: You may need to include `testnet=1` in `bitcoin.conf`

18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ CCAN_HEADERS := \
$(CCANDIR)/ccan/timer/timer.h \
$(CCANDIR)/ccan/typesafe_cb/typesafe_cb.h

GEN_HEADERS := gen_version.h
ALL_GEN_HEADERS += gen_version.h

CDUMP_OBJS := ccan-cdump.o ccan-strmap.o

Expand All @@ -143,6 +143,13 @@ include bitcoin/Makefile
include common/Makefile
include wire/Makefile
include wallet/Makefile
include hsmd/Makefile
include handshaked/Makefile
include gossipd/Makefile
include openingd/Makefile
include channeld/Makefile
include closingd/Makefile
include onchaind/Makefile
include lightningd/Makefile
include cli/Makefile
include test/Makefile
Expand All @@ -154,7 +161,7 @@ CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o
check:
$(MAKE) pytest

pytest: cli/lightning-cli lightningd-all
pytest: $(ALL_PROGRAMS)
PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f

# Keep includes in alpha order.
Expand Down Expand Up @@ -233,8 +240,11 @@ $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS):
# Everything depends on the CCAN headers.
$(CCAN_OBJS) $(CDUMP_OBJS): $(CCAN_HEADERS)

# Except for CCAN, we treat everything else as dependent on external/ bitcoin/ common/ wire/ and generated version headers.
$(ALL_OBJS): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(GEN_HEADERS) $(EXTERNAL_HEADERS)
# Except for CCAN, we treat everything else as dependent on external/ bitcoin/ common/ wire/ and all generated headers.
$(ALL_OBJS): $(BITCOIN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(ALL_GEN_HEADERS) $(EXTERNAL_HEADERS)

# We generate headers in two ways, so regen when either changes.
$(ALL_GEN_HEADERS): ccan/ccan/cdump/tools/cdump-enumstr $(WIRE_GEN)

update-ccan:
mv ccan ccan.old
Expand Down
38 changes: 20 additions & 18 deletions lightningd/channel/Makefile → channeld/Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
#! /usr/bin/make

# Designed to be run one level up
lightningd/channel-wrongdir:
channeld-wrongdir:
$(MAKE) -C ../.. lightningd/channel-all

default: lightningd/channel-all
default: channeld-all

lightningd/channel-all: lightningd/lightningd_channel
channeld-all: lightningd/lightning_channeld

# lightningd/channel needs these:
LIGHTNINGD_CHANNEL_HEADERS_GEN := \
lightningd/channel/gen_channel_wire.h
channeld/gen_channel_wire.h

LIGHTNINGD_CHANNEL_HEADERS_NOGEN := \
lightningd/channel/channeld_htlc.h \
lightningd/channel/commit_tx.h \
lightningd/channel/full_channel.h
channeld/channeld_htlc.h \
channeld/commit_tx.h \
channeld/full_channel.h

LIGHTNINGD_CHANNEL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN)

LIGHTNINGD_CHANNEL_SRC := lightningd/channel/channel.c \
lightningd/channel/commit_tx.c \
lightningd/channel/full_channel.c \
LIGHTNINGD_CHANNEL_SRC := channeld/channel.c \
channeld/commit_tx.c \
channeld/full_channel.c \
$(LIGHTNINGD_CHANNEL_HEADERS_GEN:.h=.c)
LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o)

# Make sure these depend on everything.
ALL_OBJS += $(LIGHTNINGD_CHANNEL_OBJS)
ALL_PROGRAMS += lightningd/lightning_channeld
ALL_GEN_HEADERS += $(LIGHTNINGD_CHANNEL_HEADERS_GEN)

# Common source we use.
CHANNELD_COMMON_OBJS := \
Expand Down Expand Up @@ -61,25 +63,25 @@ LIGHTNINGD_CHANNEL_CONTROL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN)
LIGHTNINGD_CHANNEL_CONTROL_SRC := $(LIGHTNINGD_CHANNEL_HEADERS_GEN:.h=.c)
LIGHTNINGD_CHANNEL_CONTROL_OBJS := $(LIGHTNINGD_CHANNEL_CONTROL_SRC:.c=.o)

LIGHTNINGD_CHANNEL_GEN_SRC := $(filter lightningd/channel/gen_%, $(LIGHTNINGD_CHANNEL_SRC) $(LIGHTNINGD_CHANNEL_CONTROL_SRC))
LIGHTNINGD_CHANNEL_GEN_SRC := $(filter channeld/gen_%, $(LIGHTNINGD_CHANNEL_SRC) $(LIGHTNINGD_CHANNEL_CONTROL_SRC))

LIGHTNINGD_CHANNEL_SRC_NOGEN := $(filter-out lightningd/channel/gen_%, $(LIGHTNINGD_CHANNEL_SRC))
LIGHTNINGD_CHANNEL_SRC_NOGEN := $(filter-out channeld/gen_%, $(LIGHTNINGD_CHANNEL_SRC))

# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CHANNEL_HEADERS_GEN)
LIGHTNINGD_HEADERS_NOGEN += $(LIGHTNINGD_CHANNEL_HEADERS_NOGEN)

$(LIGHTNINGD_CHANNEL_OBJS): $(LIGHTNINGD_HEADERS)

lightningd/channel/gen_channel_wire.h: $(WIRE_GEN) lightningd/channel/channel_wire.csv
$(WIRE_GEN) --header $@ channel_wire_type < lightningd/channel/channel_wire.csv > $@
channeld/gen_channel_wire.h: $(WIRE_GEN) channeld/channel_wire.csv
$(WIRE_GEN) --header $@ channel_wire_type < channeld/channel_wire.csv > $@

lightningd/channel/gen_channel_wire.c: $(WIRE_GEN) lightningd/channel/channel_wire.csv
$(WIRE_GEN) ${@:.c=.h} channel_wire_type < lightningd/channel/channel_wire.csv > $@
channeld/gen_channel_wire.c: $(WIRE_GEN) channeld/channel_wire.csv
$(WIRE_GEN) ${@:.c=.h} channel_wire_type < channeld/channel_wire.csv > $@

LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o) $(LIGHTNINGD_CHANNEL_GEN_SRC:.c=.o)

lightningd/lightningd_channel: $(LIGHTNINGD_CHANNEL_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
lightningd/lightning_channeld: $(LIGHTNINGD_CHANNEL_OBJS) $(WIRE_ONION_OBJS) $(CHANNELD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)

check-source: $(LIGHTNINGD_CHANNEL_SRC_NOGEN:%=check-src-include-order/%)
check-source-bolt: $(LIGHTNINGD_CHANNEL_SRC:%=bolt-check/%) $(LIGHTNINGD_CHANNEL_HEADERS:%=bolt-check/%)
Expand All @@ -91,4 +93,4 @@ clean: lightningd/channel-clean
lightningd/channel-clean:
$(RM) $(LIGHTNINGD_CHANNEL_OBJS) gen_*

-include lightningd/channel/test/Makefile
-include channeld/test/Makefile
10 changes: 5 additions & 5 deletions lightningd/channel/channel.c → channeld/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <ccan/take/take.h>
#include <ccan/tal/str/str.h>
#include <ccan/time/time.h>
#include <channeld/commit_tx.h>
#include <channeld/full_channel.h>
#include <channeld/gen_channel_wire.h>
#include <common/crypto_sync.h>
#include <common/cryptomsg.h>
#include <common/daemon_conn.h>
Expand All @@ -27,12 +30,9 @@
#include <common/type_to_string.h>
#include <common/version.h>
#include <errno.h>
#include <gossipd/routing.h>
#include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h>
#include <lightningd/channel/commit_tx.h>
#include <lightningd/channel/full_channel.h>
#include <lightningd/channel/gen_channel_wire.h>
#include <lightningd/gossip/routing.h>
#include <lightningd/hsm/gen_hsm_client_wire.h>
#include <secp256k1.h>
#include <signal.h>
#include <stdio.h>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_CHANNELD_HTLC_H
#define LIGHTNING_LIGHTNINGD_CHANNEL_CHANNELD_HTLC_H
#include "config.h"
#include <bitcoin/locktime.h>
#include <ccan/short_types/short_types.h>
#include <common/htlc.h>
#include <common/pseudorand.h>
#include <wire/gen_onion_wire.h>

Expand Down
2 changes: 1 addition & 1 deletion lightningd/channel/commit_tx.c → channeld/commit_tx.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <bitcoin/script.h>
#include <bitcoin/tx.h>
#include <ccan/endian/endian.h>
#include <channeld/commit_tx.h>
#include <common/htlc_tx.h>
#include <common/keyset.h>
#include <common/permute_tx.h>
#include <common/utils.h>
#include <lightningd/channel/commit_tx.h>

#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
Expand Down
2 changes: 1 addition & 1 deletion lightningd/channel/commit_tx.h → channeld/commit_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define LIGHTNING_LIGHTNINGD_CHANNEL_COMMIT_TX_H
#include "config.h"
#include <bitcoin/pubkey.h>
#include <channeld/channeld_htlc.h>
#include <common/htlc.h>
#include <common/initial_commit_tx.h>
#include <lightningd/channel/channeld_htlc.h>

struct keyset;
struct sha256_double;
Expand Down
4 changes: 2 additions & 2 deletions lightningd/channel/full_channel.c → channeld/full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <ccan/mem/mem.h>
#include <ccan/structeq/structeq.h>
#include <ccan/tal/str/str.h>
#include <channeld/commit_tx.h>
#include <channeld/full_channel.h>
#include <common/channel_config.h>
#include <common/htlc.h>
#include <common/htlc_tx.h>
Expand All @@ -15,8 +17,6 @@
#include <common/status.h>
#include <common/type_to_string.h>
#include <inttypes.h>
#include <lightningd/channel/commit_tx.h>
#include <lightningd/channel/full_channel.h>
#include <string.h>

struct channel *new_channel(const tal_t *ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_FULL_CHANNEL_H
#define LIGHTNING_LIGHTNINGD_CHANNEL_FULL_CHANNEL_H
#include "config.h"
#include <channeld/channeld_htlc.h>
#include <common/initial_channel.h>
#include <common/sphinx.h>
#include <lightningd/channel/channeld_htlc.h>

/**
* new_channel: Given initial fees and funding, what is initial state?
Expand Down
36 changes: 19 additions & 17 deletions lightningd/closing/Makefile → closingd/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
#! /usr/bin/make

# Designed to be run one level up
lightningd/closing-wrongdir:
$(MAKE) -C ../.. lightningd/closing-all
closingd-wrongdir:
$(MAKE) -C ../.. closingd-all

default: lightningd/closing-all
default: closingd-all

lightningd/closing-all: lightningd/lightningd_closing
closingd-all: lightningd/lightning_closingd

# lightningd/closing needs these:
# closingd needs these:
LIGHTNINGD_CLOSING_HEADERS_GEN := \
lightningd/closing/gen_closing_wire.h
closingd/gen_closing_wire.h

LIGHTNINGD_CLOSING_HEADERS_NOGEN :=

LIGHTNINGD_CLOSING_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS_GEN) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN)

LIGHTNINGD_CLOSING_SRC := lightningd/closing/closing.c \
LIGHTNINGD_CLOSING_SRC := closingd/closing.c \
$(LIGHTNINGD_CLOSING_HEADERS:.h=.c)
LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o)

# Make sure these depend on everything.
ALL_OBJS += $(LIGHTNINGD_CLOSING_OBJS)
ALL_PROGRAMS += lightningd/lightning_closingd
ALL_GEN_HEADERS += $(LIGHTNINGD_CLOSING_HEADERS_GEN)

# Control daemon uses this:
LIGHTNINGD_CLOSING_CONTROL_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS)
LIGHTNINGD_CLOSING_CONTROL_SRC := $(LIGHTNINGD_CLOSING_HEADERS:.h=.c)
LIGHTNINGD_CLOSING_CONTROL_OBJS := $(LIGHTNINGD_CLOSING_CONTROL_SRC:.c=.o)

LIGHTNINGD_CLOSING_GEN_SRC := $(filter lightningd/closing/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))
LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))

LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out lightningd/closing/gen_%, $(LIGHTNINGD_CLOSING_SRC))
LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC))

# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CLOSING_HEADERS_GEN)
Expand All @@ -55,24 +57,24 @@ CLOSINGD_COMMON_OBJS := \
common/utils.o \
common/version.o

lightningd/closing/gen_closing_wire.h: $(WIRE_GEN) lightningd/closing/closing_wire.csv
$(WIRE_GEN) --header $@ closing_wire_type < lightningd/closing/closing_wire.csv > $@
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --header $@ closing_wire_type < closingd/closing_wire.csv > $@

lightningd/closing/gen_closing_wire.c: $(WIRE_GEN) lightningd/closing/closing_wire.csv
$(WIRE_GEN) ${@:.c=.h} closing_wire_type < lightningd/closing/closing_wire.csv > $@
closingd/gen_closing_wire.c: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) ${@:.c=.h} closing_wire_type < closingd/closing_wire.csv > $@

LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) $(LIGHTNINGD_CLOSING_GEN_SRC:.c=.o)

lightningd/lightningd_closing: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS)
lightningd/lightning_closingd: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS)

check-source: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-src-include-order/%)
check-source-bolt: $(LIGHTNINGD_CLOSING_SRC:%=bolt-check/%) $(LIGHTNINGD_CLOSING_HEADERS:%=bolt-check/%)

check-whitespace: $(LIGHTNINGD_CLOSING_SRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CLOSING_HEADERS_NOGEN:%=check-whitespace/%)

clean: lightningd/closing-clean
clean: closingd-clean

lightningd/closing-clean:
closingd-clean:
$(RM) $(LIGHTNINGD_CLOSING_OBJS) gen_*

-include lightningd/closing/test/Makefile
-include closingd/test/Makefile
2 changes: 1 addition & 1 deletion lightningd/closing/closing.c → closingd/closing.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <bitcoin/script.h>
#include <closingd/gen_closing_wire.h>
#include <common/close_tx.h>
#include <common/crypto_sync.h>
#include <common/debug.h>
Expand All @@ -10,7 +11,6 @@
#include <common/version.h>
#include <errno.h>
#include <inttypes.h>
#include <lightningd/closing/gen_closing_wire.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ COMMON_OBJS := $(COMMON_SRC:.c=.o)
# Common objects depends on bitcoin/ external/ and ccan
$(COMMON_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) $(COMMON_HEADERS_GEN)

ALL_GEN_HEADERS += $(COMMON_HEADERS_GEN)
ALL_OBJS += $(COMMON_OBJS)

common/gen_htlc_state_names.h: common/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr
ccan/ccan/cdump/tools/cdump-enumstr common/htlc_state.h > $@

Expand Down
8 changes: 8 additions & 0 deletions external/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
libbase58.a
libjsmn.a
libsecp256k1.a
libsecp256k1.la
libsodium.a
libsodium.la
libwallycore.a
libwallycore.la
Loading

0 comments on commit bbed5e3

Please sign in to comment.