Skip to content

Commit ffce819

Browse files
committed
lightningd: neaten delete_channel.
Use convenience variables. Signed-off-by: Rusty Russell <[email protected]>
1 parent ade9138 commit ffce819

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lightningd/channel.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,21 @@ static void destroy_channel(struct channel *channel)
9191
void delete_channel(struct channel *channel STEALS, bool completely_eliminate)
9292
{
9393
const u8 *msg;
94-
9594
struct peer *peer = channel->peer;
95+
struct lightningd *ld = peer->ld;
96+
9697
if (channel->dbid != 0) {
97-
wallet_channel_close(channel->peer->ld->wallet, channel->dbid);
98+
wallet_channel_close(ld->wallet, channel->dbid);
9899
/* Never open at all, not ours. */
99100
if (completely_eliminate)
100-
wallet_channel_delete(channel->peer->ld->wallet, channel);
101+
wallet_channel_delete(ld->wallet, channel);
101102
}
102103

103104
/* Tell the hsm to forget the channel, needs to be after it's
104105
* been forgotten here */
105-
if (hsm_capable(channel->peer->ld, WIRE_HSMD_FORGET_CHANNEL)) {
106-
msg = towire_hsmd_forget_channel(NULL, &channel->peer->id, channel->dbid);
107-
msg = hsm_sync_req(tmpctx, channel->peer->ld, take(msg));
106+
if (hsm_capable(ld, WIRE_HSMD_FORGET_CHANNEL)) {
107+
msg = towire_hsmd_forget_channel(NULL, &peer->id, channel->dbid);
108+
msg = hsm_sync_req(tmpctx, ld, take(msg));
108109
if (!fromwire_hsmd_forget_channel_reply(msg))
109110
fatal("HSM gave bad hsm_forget_channel_reply %s", tal_hex(msg, msg));
110111
}

0 commit comments

Comments
 (0)