mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-07 08:04:23 +01:00
lightningd/peer_control: don't create peer struct until we've connected.
We currently create a peer struct, then complete handshake to find out who it is. This means we have a half-formed peer, and worse: if it's a reconnect we get two peers the same. Add an explicit 'struct connection' for the handshake phase, and construct a 'struct peer' once that's done. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -112,17 +112,6 @@ static void peer_ready(struct subd *gossip, const u8 *msg)
|
||||
type_to_string(msg, struct pubkey, peer->id),
|
||||
unique_id);
|
||||
|
||||
if (peer->connect_cmd) {
|
||||
struct json_result *response;
|
||||
response = new_json_result(peer->connect_cmd);
|
||||
|
||||
json_object_start(response, NULL);
|
||||
json_add_pubkey(response, "id", peer->id);
|
||||
json_object_end(response);
|
||||
command_success(peer->connect_cmd, response);
|
||||
peer->connect_cmd = NULL;
|
||||
}
|
||||
|
||||
peer_set_condition(peer, GOSSIPING);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user