Browse Source

lightningd/peer_control: start of reconnect logic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
61a2ed97e1
  1. 1
      daemon/log.c
  2. 19
      lightningd/peer_control.c

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

19
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)

Loading…
Cancel
Save