mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
lightningd: make "is peer connected" a tristate.
First, connectd tells us the peer has connected, and we call the connected hook, and if it says it's fine, we are actually connected and we fire off notifications. Of course, we could be disconnected while in the connected hook, and that would mean we tell people about a connection which is no longer current. Make this clear with a tristate: if we're not marked disconnected by the time the hooks finish, we're good. It also gives us a cleaner "connect" command return when we connected but disconnected before processing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
571f0fad1b
commit
eff53495db
@@ -963,9 +963,11 @@ static struct command_result *json_fundchannel_complete(struct command *cmd,
|
||||
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||
}
|
||||
|
||||
if (!peer->is_connected)
|
||||
if (peer->connected != PEER_CONNECTED)
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Peer not connected");
|
||||
"Peer %s",
|
||||
peer->connected == PEER_DISCONNECTED
|
||||
? "not connected" : "still connecting");
|
||||
|
||||
if (!peer->uncommitted_channel
|
||||
|| !peer->uncommitted_channel->fc
|
||||
@@ -1136,9 +1138,11 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
||||
return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
|
||||
}
|
||||
|
||||
if (!peer->is_connected)
|
||||
if (peer->connected != PEER_CONNECTED)
|
||||
return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
|
||||
"Peer not connected");
|
||||
"Peer %s",
|
||||
peer->connected == PEER_DISCONNECTED
|
||||
? "not connected" : "still connecting");
|
||||
|
||||
temporary_channel_id(&tmp_channel_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user