connectd: control connect backoff from lightningd.

We used to tell connectd to remember our connect delay, and hand it
back (increased if necessary).

Instead, simply record when we last tried to connect.  If it was less
than 10 minutes ago, double delay (up to 5 minutes max), otherwise
reset delay to 1 second.

This covers all scenarios: whether we reconnect then immediately
disconnect, or never successfully connect, it doesn't matter.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: #5453
This commit is contained in:
Rusty Russell
2022-07-28 11:00:36 +09:30
parent 9cad7d6a6a
commit 22ff007d64
13 changed files with 54 additions and 77 deletions

View File

@@ -47,7 +47,6 @@ msgdata,connectd_activate_reply,failmsg,?wirestring,
# Master -> connectd: connect to a peer.
msgtype,connectd_connect_to_peer,2001
msgdata,connectd_connect_to_peer,id,node_id,
msgdata,connectd_connect_to_peer,seconds_waited,u32,
msgdata,connectd_connect_to_peer,len,u32,
msgdata,connectd_connect_to_peer,addrs,wireaddr,len
msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal,
@@ -57,7 +56,6 @@ msgtype,connectd_connect_failed,2020
msgdata,connectd_connect_failed,id,node_id,
msgdata,connectd_connect_failed,failcode,errcode_t,
msgdata,connectd_connect_failed,failreason,wirestring,
msgdata,connectd_connect_failed,seconds_to_delay,u32,
msgdata,connectd_connect_failed,addrhint,?wireaddr_internal,
# Connectd -> master: we got a peer.
1 #include <bitcoin/block.h>
47 msgdata,connectd_connect_to_peer,addrs,wireaddr,len msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal,
48 msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal, # Connectd->master: connect failed.
49 # Connectd->master: connect failed. msgtype,connectd_connect_failed,2020
msgtype,connectd_connect_failed,2020
50 msgdata,connectd_connect_failed,id,node_id,
51 msgdata,connectd_connect_failed,failcode,errcode_t,
52 msgdata,connectd_connect_failed,failreason,wirestring,
56 msgtype,connectd_peer_connected,2002 msgdata,connectd_peer_connected,id,node_id,
57 msgdata,connectd_peer_connected,id,node_id, msgdata,connectd_peer_connected,counter,u64,
58 msgdata,connectd_peer_connected,counter,u64, msgdata,connectd_peer_connected,addr,wireaddr_internal,
msgdata,connectd_peer_connected,addr,wireaddr_internal,
59 msgdata,connectd_peer_connected,remote_addr,?wireaddr,
60 msgdata,connectd_peer_connected,incoming,bool,
61 msgdata,connectd_peer_connected,flen,u16,