diff --git a/daemon/log.c b/daemon/log.c index d34ee20ba..83d2446f8 100644 --- a/daemon/log.c +++ b/daemon/log.c @@ -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; diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 1fc62e2a6..08e0abb51 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -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)