diff --git a/connectd/connectd.c b/connectd/connectd.c index 7c730e5ad..d11ac452c 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -633,6 +633,13 @@ static void connect_failed(struct daemon *daemon, status_peer_debug(id, "Failed connected out: %s", errmsg); } +/* add errors to error list */ +void add_errors_to_error_list(struct connecting *connect, const char *error) +{ + tal_append_fmt(&connect->errors, + "%s. ", error); +} + /*~ This is the destructor for the (unsuccessful) connection. We accumulate * the errors which occurred, so we can report to lightningd properly in case * they all fail, and try the next address. @@ -650,11 +657,12 @@ static void destroy_io_conn(struct io_conn *conn, struct connecting *connect) if (streq(connect->connstate, "Cryptographic handshake")) errstr = "peer closed connection (wrong key?)"; } - tal_append_fmt(&connect->errors, - "%s: %s: %s. ", + + add_errors_to_error_list(connect, + tal_fmt(tmpctx, "%s: %s: %s", type_to_string(tmpctx, struct wireaddr_internal, &connect->addrs[connect->addrnum]), - connect->connstate, errstr); + connect->connstate, errstr)); connect->addrnum++; try_connect_one_addr(connect); } diff --git a/connectd/connectd.h b/connectd/connectd.h index e5fbd35b4..fbe7c6d0b 100644 --- a/connectd/connectd.h +++ b/connectd/connectd.h @@ -13,6 +13,9 @@ struct wireaddr_internal; /* Called by io_tor_connect once it has a connection out. */ struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect); +/* add erros to error list */ +void add_errors_to_error_list(struct connecting *connect, const char *error); + /* Called by peer_exchange_initmsg if successful. */ struct io_plan *peer_connected(struct io_conn *conn, struct daemon *daemon,