mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
rbf: consolidate failure paths, use "warnings"
We move over to the new "warning" paradigm, instead of using an "rbf_fail" message. Every failure is either a warning or an error; on warnings we hang up and reconnect later, effectively resetting the state.
This commit is contained in:
@@ -105,7 +105,6 @@ static void handle_signed_psbt(struct lightningd *ld,
|
||||
&txid),
|
||||
type_to_string(tmpctx, struct bitcoin_txid,
|
||||
&inflight->funding->txid));
|
||||
/* FIXME: what's the ideal error handling here ? */
|
||||
subd_send_msg(dualopend,
|
||||
take(towire_dualopend_fail(NULL,
|
||||
"Peer error with PSBT"
|
||||
@@ -1206,72 +1205,6 @@ static void handle_channel_closed(struct subd *dualopend,
|
||||
"Start closingd");
|
||||
}
|
||||
|
||||
static void
|
||||
opening_failed_cancel_commands(struct channel *channel,
|
||||
struct open_attempt *oa,
|
||||
const char *desc)
|
||||
{
|
||||
if (oa->cmd)
|
||||
was_pending(command_fail(oa->cmd, LIGHTNINGD, "%s", desc));
|
||||
|
||||
/* FIXME: cancels? */
|
||||
|
||||
channel->open_attempt = tal_free(channel->open_attempt);
|
||||
if (list_empty(&channel->inflights))
|
||||
memset(&channel->cid, 0xFF, sizeof(channel->cid));
|
||||
}
|
||||
|
||||
static void open_failed(struct subd *dualopend, const u8 *msg)
|
||||
{
|
||||
char *desc;
|
||||
struct channel *channel = dualopend->channel;
|
||||
struct open_attempt *oa = channel->open_attempt;
|
||||
|
||||
if (!fromwire_dualopend_failed(msg, msg, &desc)) {
|
||||
log_broken(channel->log,
|
||||
"Bad DUALOPEND_FAILED %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
if (oa->cmd)
|
||||
was_pending(command_fail(oa->cmd, LIGHTNINGD, "%s",
|
||||
tal_hex(oa->cmd, msg)));
|
||||
|
||||
notify_channel_open_failed(dualopend->ld, &channel->cid);
|
||||
subd_release_channel(dualopend, channel);
|
||||
channel->open_attempt = tal_free(channel->open_attempt);
|
||||
return;
|
||||
}
|
||||
|
||||
notify_channel_open_failed(dualopend->ld, &channel->cid);
|
||||
opening_failed_cancel_commands(channel, oa, desc);
|
||||
}
|
||||
|
||||
static void rbf_failed(struct subd *dualopend, const u8 *msg)
|
||||
{
|
||||
char *desc;
|
||||
struct channel *channel = dualopend->channel;
|
||||
struct open_attempt *oa = channel->open_attempt;
|
||||
|
||||
if (!fromwire_dualopend_rbf_failed(msg, msg, &desc)) {
|
||||
channel_internal_error(channel,
|
||||
"Bad DUALOPEND_RBF_FAILED %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
if (oa->cmd)
|
||||
was_pending(command_fail(oa->cmd, LIGHTNINGD, "%s",
|
||||
tal_hex(oa->cmd, msg)));
|
||||
|
||||
/* FIXME: notify rbf_failed? */
|
||||
notify_channel_open_failed(dualopend->ld, &channel->cid);
|
||||
channel->open_attempt = tal_free(channel->open_attempt);
|
||||
return;
|
||||
}
|
||||
|
||||
/* FIXME: notify rbf_failed? */
|
||||
notify_channel_open_failed(dualopend->ld, &channel->cid);
|
||||
opening_failed_cancel_commands(channel, oa, desc);
|
||||
}
|
||||
|
||||
struct channel_send {
|
||||
const struct wally_tx *wtx;
|
||||
struct channel *channel;
|
||||
@@ -2513,12 +2446,6 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
|
||||
case WIRE_DUALOPEND_FAIL_FALLEN_BEHIND:
|
||||
channel_fail_fallen_behind(dualopend, msg);
|
||||
return 0;
|
||||
case WIRE_DUALOPEND_FAILED:
|
||||
open_failed(dualopend, msg);
|
||||
return 0;
|
||||
case WIRE_DUALOPEND_RBF_FAILED:
|
||||
rbf_failed(dualopend, msg);
|
||||
return 0;
|
||||
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
|
||||
|
||||
/* Messages we send */
|
||||
|
||||
@@ -391,6 +391,16 @@ void channel_errmsg(struct channel *channel,
|
||||
if (err_for_them && !channel->error && !warning)
|
||||
channel->error = tal_dup_talarr(channel, u8, err_for_them);
|
||||
|
||||
/* Clean up any in-progress open attempts */
|
||||
if (channel->open_attempt) {
|
||||
struct open_attempt *oa = channel->open_attempt;
|
||||
if (oa->cmd)
|
||||
was_pending(command_fail(oa->cmd, LIGHTNINGD,
|
||||
"%s", desc));
|
||||
notify_channel_open_failed(channel->peer->ld, &channel->cid);
|
||||
channel->open_attempt = tal_free(channel->open_attempt);
|
||||
}
|
||||
|
||||
/* Other implementations chose to ignore errors early on. Not
|
||||
* surprisingly, they now spew out spurious errors frequently,
|
||||
* and we would close the channel on them. We now support warnings
|
||||
@@ -2643,6 +2653,7 @@ static const struct json_command sendcustommsg_command = {
|
||||
.verbose = "dev-sendcustommsg node_id hexcustommsg",
|
||||
};
|
||||
|
||||
/* Comment added to satisfice AUTODATA */
|
||||
AUTODATA(json_command, &sendcustommsg_command);
|
||||
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
@@ -402,6 +402,10 @@ int node_id_cmp(const struct node_id *a UNNEEDED, const struct node_id *b UNNEED
|
||||
/* Generated stub for node_id_to_hexstr */
|
||||
char *node_id_to_hexstr(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
|
||||
{ fprintf(stderr, "node_id_to_hexstr called!\n"); abort(); }
|
||||
/* Generated stub for notify_channel_open_failed */
|
||||
void notify_channel_open_failed(struct lightningd *ld UNNEEDED,
|
||||
const struct channel_id *cid UNNEEDED)
|
||||
{ fprintf(stderr, "notify_channel_open_failed called!\n"); abort(); }
|
||||
/* Generated stub for notify_connect */
|
||||
void notify_connect(struct lightningd *ld UNNEEDED, struct node_id *nodeid UNNEEDED,
|
||||
struct wireaddr_internal *addr UNNEEDED)
|
||||
|
||||
Reference in New Issue
Block a user