mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
gossip: Directly return an error if we don't know a node's address
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
61e982c6b7
commit
acc6afc8de
@ -1573,9 +1573,10 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
|
||||
status_trace("Failed to connect after %d attempts, giving up "
|
||||
"after %d seconds",
|
||||
reach->attempts, diff);
|
||||
daemon_conn_send(&reach->daemon->master,
|
||||
take(towire_gossip_peer_connection_failed(
|
||||
conn, &reach->id, diff, reach->attempts)));
|
||||
daemon_conn_send(
|
||||
&reach->daemon->master,
|
||||
take(towire_gossip_peer_connection_failed(
|
||||
conn, &reach->id, diff, reach->attempts, false)));
|
||||
tal_free(reach);
|
||||
} else {
|
||||
status_trace("Failed connected out for %s, will try again",
|
||||
@ -1645,6 +1646,12 @@ static void try_connect(struct reaching *reach)
|
||||
/* FIXME: add reach_failed message */
|
||||
status_trace("No address known for %s, giving up",
|
||||
type_to_string(trc, struct pubkey, &reach->id));
|
||||
daemon_conn_send(
|
||||
&reach->daemon->master,
|
||||
take(towire_gossip_peer_connection_failed(
|
||||
reach, &reach->id,
|
||||
time_now().ts.tv_sec - reach->first_attempt,
|
||||
reach->attempts, true)));
|
||||
tal_free(reach);
|
||||
return;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ gossip_peer_connection_failed,3020
|
||||
gossip_peer_connection_failed,,id,struct pubkey
|
||||
gossip_peer_connection_failed,,timeout,u32
|
||||
gossip_peer_connection_failed,,attempts,u32
|
||||
gossip_peer_connection_failed,,addr_unknown,bool
|
||||
|
||||
# Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip
|
||||
gossip_peer_nongossip,3003
|
||||
|
|
@ -610,20 +610,32 @@ void peer_connection_failed(struct lightningd *ld, const u8 *msg)
|
||||
{
|
||||
struct pubkey id;
|
||||
u32 attempts, timediff;
|
||||
struct connect *i, *next;
|
||||
if (!fromwire_gossip_peer_connection_failed(msg, NULL, &id, &attempts, &timediff))
|
||||
fatal("Gossip gave bad GOSSIP_PEER_CONNECTION_FAILED message %s", tal_hex(msg, msg));
|
||||
struct connect *i, *next;
|
||||
bool addr_unknown;
|
||||
char *error;
|
||||
|
||||
if (!fromwire_gossip_peer_connection_failed(msg, NULL, &id, &attempts,
|
||||
&timediff, &addr_unknown))
|
||||
fatal(
|
||||
"Gossip gave bad GOSSIP_PEER_CONNECTION_FAILED message %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
if (addr_unknown) {
|
||||
error = tal_fmt(
|
||||
msg, "No address known for node %s, please provide one",
|
||||
type_to_string(msg, struct pubkey, &id));
|
||||
} else {
|
||||
error = tal_fmt(msg, "Could not connect to %s after %d seconds and %d attempts",
|
||||
type_to_string(msg, struct pubkey, &id), timediff,
|
||||
attempts);
|
||||
}
|
||||
|
||||
/* Careful! Completing command frees connect. */
|
||||
list_for_each_safe(&ld->connects, i, next, list) {
|
||||
if (!pubkey_eq(&i->id, &id))
|
||||
continue;
|
||||
|
||||
command_fail(
|
||||
i->cmd,
|
||||
"Could not connect to %s after %d seconds and %d attempts",
|
||||
type_to_string(msg, struct pubkey, &id), timediff,
|
||||
attempts);
|
||||
command_fail(i->cmd, "%s", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user