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:
Rusty Russell
2017-05-22 20:56:49 +09:30
parent 61a2ed97e1
commit f6495d3310
8 changed files with 256 additions and 195 deletions

View File

@@ -193,8 +193,6 @@ class LightningDTests(BaseLightningDTests):
assert p2['state'] == 'GOSSIPING'
# It should have gone through these steps
print(p1['log'])
assert 'state: HANDSHAKING -> INITIALIZING' in p1['log']
assert 'state: INITIALIZING -> GOSSIPING' in p1['log']
# Both should still be owned by gossip