Skip to content

Commit

Permalink
chore: cleanup some nits
Browse files Browse the repository at this point in the history
rearranges the`peer_connected_hook_payload` definition to the location
where this is used in the file.

Fixes certain blanklines and linebreaks to make the code look nicer.
  • Loading branch information
m-schmoock authored and rustyrussell committed Jan 31, 2021
1 parent bc40287 commit 9eeb290
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,6 @@ void channel_errmsg(struct channel *channel,
err_for_them ? "sent" : "received", desc);
}

struct peer_connected_hook_payload {
struct lightningd *ld;
struct channel *channel;
struct wireaddr_internal addr;
struct peer *peer;
struct per_peer_state *pps;
u8 *error;
};

static void json_add_htlcs(struct lightningd *ld,
struct json_stream *response,
const struct channel *channel)
Expand Down Expand Up @@ -933,6 +924,15 @@ static void json_add_channel(struct lightningd *ld,
json_object_end(response);
}

struct peer_connected_hook_payload {
struct lightningd *ld;
struct channel *channel;
struct wireaddr_internal addr;
struct peer *peer;
struct per_peer_state *pps;
u8 *error;
};

static void
peer_connected_serialize(struct peer_connected_hook_payload *payload,
struct json_stream *stream)
Expand Down Expand Up @@ -978,8 +978,7 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa

#if DEVELOPER
if (dev_disconnect_permanent(ld)) {
channel_fail_permanent(channel,
REASON_LOCAL,
channel_fail_permanent(channel, REASON_LOCAL,
"dev_disconnect permfail");
error = channel->error;
goto send_error;
Expand Down Expand Up @@ -1008,11 +1007,8 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
case DUALOPEND_AWAITING_LOCKIN:
#if EXPERIMENTAL_FEATURES
assert(!channel->owner);

channel->peer->addr = addr;
peer_restart_dualopend(peer, payload->pps,
channel, NULL);

peer_restart_dualopend(peer, payload->pps, channel, NULL);
return;
#else
abort();
Expand All @@ -1021,18 +1017,14 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
case CHANNELD_NORMAL:
case CHANNELD_SHUTTING_DOWN:
assert(!channel->owner);

channel->peer->addr = addr;
peer_start_channeld(channel, payload->pps,
NULL, true);
peer_start_channeld(channel, payload->pps, NULL, true);
return;

case CLOSINGD_SIGEXCHANGE:
assert(!channel->owner);

channel->peer->addr = addr;
peer_start_closingd(channel, payload->pps,
true, NULL);
peer_start_closingd(channel, payload->pps, true, NULL);
return;
}
abort();
Expand All @@ -1052,12 +1044,10 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
* dualopend. we only get here if there's an error */
if (channel) {
assert(!channel->owner);

assert(channel->state == DUALOPEND_OPEN_INIT
|| channel->state == DUALOPEND_AWAITING_LOCKIN);
channel->peer->addr = addr;
peer_restart_dualopend(peer, payload->pps,
channel, error);
peer_restart_dualopend(peer, payload->pps, channel, error);
} else
peer_start_dualopend(peer, payload->pps, error);
} else
Expand Down

0 comments on commit 9eeb290

Please sign in to comment.