gossipd: make sure master only ever sees one active connection.

When we get a reconnection, kill the current remote peer, and wait for the
master to tell us it's dead.  Then we hand it the new peer.

Previously, we would end up with gossipd holding multiple peers, and
the logging was really hard to interpret; I'm not completely convinced
that we did the right thing when one terminated, either.

Note that this now means we can have peers with neither ->local nor ->remote
populated, so we check that more carefully.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-04-26 14:21:01 +09:30
parent be1f33b265
commit bc4809aa85
4 changed files with 130 additions and 48 deletions

View File

@@ -3131,8 +3131,9 @@ class LightningDTests(BaseLightningDTests):
# Reconnect.
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
# We should get a message about reconnecting.
l2.daemon.wait_for_log('Killing openingd: Peer reconnected')
# We should get a message about reconnecting, but order unsynced.
l2.daemon.wait_for_logs(['gossipd.*reconnect for active peer',
'openingd.*Error reading gossip msg'])
# Should work fine.
l1.rpc.fundchannel(l2.info['id'], 20000)