mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
gossip: Implement connection failed handler in lightningd
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
932dbd8c2c
commit
61e982c6b7
@ -134,7 +134,7 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||
peer_already_connected(gossip->ld, msg);
|
||||
break;
|
||||
case WIRE_GOSSIP_PEER_CONNECTION_FAILED:
|
||||
/* TODO(cdecker) Implement handler */
|
||||
peer_connection_failed(gossip->ld, msg);
|
||||
break;
|
||||
case WIRE_GOSSIP_PEER_NONGOSSIP:
|
||||
if (tal_count(fds) != 2)
|
||||
|
@ -606,6 +606,29 @@ void peer_already_connected(struct lightningd *ld, const u8 *msg)
|
||||
connect_succeeded(ld, &id);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void peer_sent_nongossip(struct lightningd *ld,
|
||||
const struct pubkey *id,
|
||||
const struct wireaddr *addr,
|
||||
|
@ -179,6 +179,9 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
|
||||
/* This simply means we asked to reach a peer, but we already have it */
|
||||
void peer_already_connected(struct lightningd *ld, const u8 *msg);
|
||||
|
||||
/* We were unable to connect to the peer */
|
||||
void peer_connection_failed(struct lightningd *ld, const u8 *msg);
|
||||
|
||||
void peer_sent_nongossip(struct lightningd *ld,
|
||||
const struct pubkey *id,
|
||||
const struct wireaddr *addr,
|
||||
|
Loading…
Reference in New Issue
Block a user