mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
lightningd/peer_control: start of reconnect logic.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fe1ff33419
commit
61a2ed97e1
@ -450,6 +450,7 @@ void opt_register_logging(struct log *log)
|
||||
|
||||
static struct log *crashlog;
|
||||
|
||||
/* FIXME: Dump peer logs! */
|
||||
static void log_crash(int sig)
|
||||
{
|
||||
const char *logfile = NULL;
|
||||
|
@ -44,16 +44,31 @@ static void destroy_peer(struct peer *peer)
|
||||
peer_state_name(peer->state));
|
||||
}
|
||||
|
||||
static void peer_reconnect(struct peer *peer)
|
||||
{
|
||||
/* FIXME: Set timer, etc. */
|
||||
}
|
||||
|
||||
void peer_fail(struct peer *peer, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
log_unusual(peer->log, "Peer has failed: ");
|
||||
log_info(peer->log, "Peer failure: ");
|
||||
logv(peer->log, -1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
tal_free(peer);
|
||||
/* If we haven't reached awaiting locked, we don't need to reconnect */
|
||||
if (!peer_persists(peer)) {
|
||||
log_info(peer->log, "Only reached state %s: forgetting",
|
||||
peer_state_name(peer->state));
|
||||
tal_free(peer);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reconnect unless we've dropped to chain. */
|
||||
if (!peer_on_chain(peer))
|
||||
peer_reconnect(peer);
|
||||
}
|
||||
|
||||
void peer_set_condition(struct peer *peer, enum peer_state state)
|
||||
|
Loading…
Reference in New Issue
Block a user