Skip to content

Commit aa117f7

Browse files
committed
channeld: remove never-used "reestablish_only" option.
This was always false. peer_start_channeld was called in various places with the argument "NULL" instead of "false", which unfortunately compilers didn't complain about :( Signed-off-by: Rusty Russell <[email protected]>
1 parent d4253fc commit aa117f7

10 files changed

+12
-53
lines changed

channeld/channeld.c

+2-33
Original file line numberDiff line numberDiff line change
@@ -4987,8 +4987,7 @@ static u8 *to_bytearr(const tal_t *ctx,
49874987
}
49884988

49894989
static void peer_reconnect(struct peer *peer,
4990-
const struct secret *last_remote_per_commit_secret,
4991-
bool reestablish_only)
4990+
const struct secret *last_remote_per_commit_secret)
49924991
{
49934992
struct channel_id channel_id;
49944993
/* Note: BOLT #2 uses these names! */
@@ -5146,14 +5145,6 @@ static void peer_reconnect(struct peer *peer,
51465145
do {
51475146
clean_tmpctx();
51485147
msg = peer_read(tmpctx, peer->pps);
5149-
5150-
/* connectd promised us the msg was reestablish? */
5151-
if (reestablish_only) {
5152-
if (fromwire_peektype(msg) != WIRE_CHANNEL_REESTABLISH)
5153-
status_failed(STATUS_FAIL_INTERNAL_ERROR,
5154-
"Expected reestablish, got: %s",
5155-
tal_hex(tmpctx, msg));
5156-
}
51575148
} while (handle_peer_error_or_warning(peer->pps, msg) ||
51585149
capture_premature_msg(&premature_msgs, msg));
51595150

@@ -5501,23 +5492,6 @@ static void peer_reconnect(struct peer *peer,
55015492
set_channel_type(peer->channel, type);
55025493
}
55035494

5504-
/* Now stop, we've been polite long enough. */
5505-
if (reestablish_only) {
5506-
/* We've reestablished! */
5507-
wire_sync_write(MASTER_FD,
5508-
take(towire_channeld_reestablished(NULL)));
5509-
5510-
/* If we were successfully closing, we still go to closingd. */
5511-
if (shutdown_complete(peer)) {
5512-
send_shutdown_complete(peer);
5513-
daemon_shutdown();
5514-
exit(0);
5515-
}
5516-
peer_failed_err(peer->pps,
5517-
&peer->channel_id,
5518-
"Channel is already closed");
5519-
}
5520-
55215495
tal_free(send_tlvs);
55225496

55235497
/* We've reestablished! */
@@ -6103,7 +6077,6 @@ static void init_channel(struct peer *peer)
61036077
u32 minimum_depth, lease_expiry;
61046078
struct secret last_remote_per_commit_secret;
61056079
struct penalty_base *pbases;
6106-
bool reestablish_only;
61076080
struct channel_type *channel_type;
61086081

61096082
assert(!(fcntl(MASTER_FD, F_GETFL) & O_NONBLOCK));
@@ -6159,7 +6132,6 @@ static void init_channel(struct peer *peer)
61596132
&channel_type,
61606133
&peer->dev_disable_commit,
61616134
&pbases,
6162-
&reestablish_only,
61636135
&peer->experimental_upgrade,
61646136
&peer->splice_state->inflights,
61656137
&peer->local_alias)) {
@@ -6249,10 +6221,7 @@ static void init_channel(struct peer *peer)
62496221

62506222
/* OK, now we can process peer messages. */
62516223
if (reconnected)
6252-
peer_reconnect(peer, &last_remote_per_commit_secret,
6253-
reestablish_only);
6254-
else
6255-
assert(!reestablish_only);
6224+
peer_reconnect(peer, &last_remote_per_commit_secret);
62566225

62576226
/* If we have a messages to send, send them immediately */
62586227
if (fwd_msg)

channeld/channeld_wire.csv

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ msgdata,channeld_init,desired_type,channel_type,
7272
msgdata,channeld_init,dev_disable_commit,?u32,
7373
msgdata,channeld_init,num_penalty_bases,u32,
7474
msgdata,channeld_init,pbases,penalty_base,num_penalty_bases
75-
msgdata,channeld_init,reestablish_only,bool,
7675
msgdata,channeld_init,experimental_upgrade,bool,
7776
msgdata,channeld_init,num_inflights,u16,
7877
msgdata,channeld_init,inflights,inflight,num_inflights

lightningd/channel_control.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static void handle_splice_abort(struct lightningd *ld,
363363
return;
364364
}
365365

366-
if (peer_start_channeld(channel, pfd, NULL, false, false)) {
366+
if (peer_start_channeld(channel, pfd, NULL, false)) {
367367
subd_send_msg(ld->connectd,
368368
take(towire_connectd_peer_connect_subd(NULL,
369369
&peer->id,
@@ -1641,8 +1641,7 @@ static void channel_control_errmsg(struct channel *channel,
16411641
bool peer_start_channeld(struct channel *channel,
16421642
struct peer_fd *peer_fd,
16431643
const u8 *fwd_msg,
1644-
bool reconnected,
1645-
bool reestablish_only)
1644+
bool reconnected)
16461645
{
16471646
u8 *initmsg;
16481647
int hsmfd;
@@ -1865,7 +1864,6 @@ bool peer_start_channeld(struct channel *channel,
18651864
? NULL
18661865
: (u32 *)&ld->dev_disable_commit,
18671866
pbases,
1868-
reestablish_only,
18691867
ld->experimental_upgrade_protocol,
18701868
cast_const2(const struct inflight **,
18711869
inflights),

lightningd/channel_control.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ struct peer;
1313
bool peer_start_channeld(struct channel *channel,
1414
struct peer_fd *peer_fd,
1515
const u8 *fwd_msg,
16-
bool reconnected,
17-
bool reestablish_only);
16+
bool reconnected);
1817

1918
/* Send message to channeld (if connected) to tell it about depth
2019
* c.f. dualopen_tell_depth! */

lightningd/dual_open_control.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ static void handle_channel_locked(struct subd *dualopend,
19901990
channel_watch_funding(dualopend->ld, channel);
19911991

19921992
/* FIXME: LND sigs/update_fee msgs? */
1993-
peer_start_channeld(channel, peer_fd, NULL, false, NULL);
1993+
peer_start_channeld(channel, peer_fd, NULL, false);
19941994
return;
19951995
}
19961996

lightningd/opening_control.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
455455
tell_connectd_peer_importance(channel->peer, was_important);
456456

457457
/* If this fails, it cleans up */
458-
if (!peer_start_channeld(channel, peer_fd, NULL, false, NULL))
458+
if (!peer_start_channeld(channel, peer_fd, NULL, false))
459459
return;
460460

461461
funding_success(channel);
@@ -562,7 +562,7 @@ static void opening_fundee_finished(struct subd *openingd,
562562
wallet_penalty_base_add(ld->wallet, channel->dbid, pbase);
563563

564564
/* On to normal operation (frees if it fails!) */
565-
if (peer_start_channeld(channel, peer_fd, fwd_msg, false, NULL))
565+
if (peer_start_channeld(channel, peer_fd, fwd_msg, false))
566566
tal_free(uc);
567567
return;
568568

lightningd/peer_control.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,7 @@ static void connect_activate_subd(struct lightningd *ld, struct channel *channel
13621362

13631363
if (peer_start_channeld(channel,
13641364
pfd,
1365-
NULL, true,
1366-
NULL)) {
1365+
NULL, true)) {
13671366
goto tell_connectd;
13681367
}
13691368
close(other_fd);
@@ -1879,8 +1878,7 @@ void peer_spoke(struct lightningd *ld, const u8 *msg)
18791878
/* Tell channeld to handle reestablish, then it will call closingd */
18801879
if (peer_start_channeld(channel,
18811880
pfd,
1882-
NULL, true,
1883-
NULL)) {
1881+
NULL, true)) {
18841882
goto tell_connectd;
18851883
}
18861884
error = towire_warningfmt(tmpctx, &channel_id,

lightningd/test/run-invoice-select-inchan.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ bool peer_restart_dualopend(struct peer *peer UNNEEDED,
904904
bool peer_start_channeld(struct channel *channel UNNEEDED,
905905
struct peer_fd *peer_fd UNNEEDED,
906906
const u8 *fwd_msg UNNEEDED,
907-
bool reconnected UNNEEDED,
908-
bool reestablish_only UNNEEDED)
907+
bool reconnected UNNEEDED)
909908
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
910909
/* Generated stub for peer_start_dualopend */
911910
bool peer_start_dualopend(struct peer *peer UNNEEDED, struct peer_fd *peer_fd UNNEEDED,

tests/plugins/channeld_fakenet.c

-2
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,6 @@ static struct channel *handle_init(struct info *info, const u8 *init_msg)
10571057
u32 minimum_depth, lease_expiry;
10581058
struct secret last_remote_per_commit_secret;
10591059
struct penalty_base *pbases;
1060-
bool reestablish_only;
10611060
struct channel_type *channel_type;
10621061
u32 feerate_min, feerate_max, feerate_penalty;
10631062
struct pubkey remote_per_commit;
@@ -1137,7 +1136,6 @@ static struct channel *handle_init(struct info *info, const u8 *init_msg)
11371136
&channel_type,
11381137
&dev_disable_commit,
11391138
&pbases,
1140-
&reestablish_only,
11411139
&experimental_upgrade,
11421140
&inflights,
11431141
&local_alias))

wallet/test/run-wallet.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,7 @@ bool peer_restart_dualopend(struct peer *peer UNNEEDED,
940940
bool peer_start_channeld(struct channel *channel UNNEEDED,
941941
struct peer_fd *peer_fd UNNEEDED,
942942
const u8 *fwd_msg UNNEEDED,
943-
bool reconnected UNNEEDED,
944-
bool reestablish_only UNNEEDED)
943+
bool reconnected UNNEEDED)
945944
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
946945
/* Generated stub for peer_start_dualopend */
947946
bool peer_start_dualopend(struct peer *peer UNNEEDED, struct peer_fd *peer_fd UNNEEDED,

0 commit comments

Comments
 (0)