mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +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 "
|
status_trace("Failed to connect after %d attempts, giving up "
|
||||||
"after %d seconds",
|
"after %d seconds",
|
||||||
reach->attempts, diff);
|
reach->attempts, diff);
|
||||||
daemon_conn_send(&reach->daemon->master,
|
daemon_conn_send(
|
||||||
take(towire_gossip_peer_connection_failed(
|
&reach->daemon->master,
|
||||||
conn, &reach->id, diff, reach->attempts)));
|
take(towire_gossip_peer_connection_failed(
|
||||||
|
conn, &reach->id, diff, reach->attempts, false)));
|
||||||
tal_free(reach);
|
tal_free(reach);
|
||||||
} else {
|
} else {
|
||||||
status_trace("Failed connected out for %s, will try again",
|
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 */
|
/* FIXME: add reach_failed message */
|
||||||
status_trace("No address known for %s, giving up",
|
status_trace("No address known for %s, giving up",
|
||||||
type_to_string(trc, struct pubkey, &reach->id));
|
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);
|
tal_free(reach);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ gossip_peer_connection_failed,3020
|
|||||||
gossip_peer_connection_failed,,id,struct pubkey
|
gossip_peer_connection_failed,,id,struct pubkey
|
||||||
gossip_peer_connection_failed,,timeout,u32
|
gossip_peer_connection_failed,,timeout,u32
|
||||||
gossip_peer_connection_failed,,attempts,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
|
# Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip
|
||||||
gossip_peer_nongossip,3003
|
gossip_peer_nongossip,3003
|
||||||
|
|
@ -610,20 +610,32 @@ void peer_connection_failed(struct lightningd *ld, const u8 *msg)
|
|||||||
{
|
{
|
||||||
struct pubkey id;
|
struct pubkey id;
|
||||||
u32 attempts, timediff;
|
u32 attempts, timediff;
|
||||||
struct connect *i, *next;
|
struct connect *i, *next;
|
||||||
if (!fromwire_gossip_peer_connection_failed(msg, NULL, &id, &attempts, &timediff))
|
bool addr_unknown;
|
||||||
fatal("Gossip gave bad GOSSIP_PEER_CONNECTION_FAILED message %s", tal_hex(msg, msg));
|
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. */
|
/* Careful! Completing command frees connect. */
|
||||||
list_for_each_safe(&ld->connects, i, next, list) {
|
list_for_each_safe(&ld->connects, i, next, list) {
|
||||||
if (!pubkey_eq(&i->id, &id))
|
if (!pubkey_eq(&i->id, &id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
command_fail(
|
command_fail(i->cmd, "%s", error);
|
||||||
i->cmd,
|
|
||||||
"Could not connect to %s after %d seconds and %d attempts",
|
|
||||||
type_to_string(msg, struct pubkey, &id), timediff,
|
|
||||||
attempts);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user