lightningd/peer_control: start of reconnect logic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-05-22 20:55:01 +09:30
parent fe1ff33419
commit 61a2ed97e1
2 changed files with 18 additions and 2 deletions

View File

@ -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;

View File

@ -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);
/* 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)