node: Connect to peers on startup
We run `maintain_connections` on initialization so that we're immediately connected to some peers from our address book.
This commit is contained in:
parent
27865a26b2
commit
508cf4f68c
|
|
@ -428,6 +428,8 @@ where
|
|||
.repo_policies()?
|
||||
.filter_map(|t| (t.policy == tracking::Policy::Track).then_some(t.id)),
|
||||
);
|
||||
// Try to establish some connections.
|
||||
self.maintain_connections();
|
||||
// Start periodic tasks.
|
||||
self.outbox.wakeup(IDLE_INTERVAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1015,7 +1015,6 @@ fn test_maintain_connections() {
|
|||
];
|
||||
|
||||
let mut alice = Peer::new("alice", [7, 7, 7, 7]);
|
||||
alice.import_addresses(&unconnected);
|
||||
|
||||
for peer in connected.iter() {
|
||||
alice.connect_to(peer);
|
||||
|
|
@ -1023,8 +1022,10 @@ fn test_maintain_connections() {
|
|||
assert_eq!(
|
||||
connected.len(),
|
||||
alice.sessions().len(),
|
||||
"alice should be connected to all peers"
|
||||
"alice should be connected to the first set of peers"
|
||||
);
|
||||
// We now import the other addresses.
|
||||
alice.import_addresses(&unconnected);
|
||||
|
||||
// A transient error such as this will cause Alice to attempt a reconnection.
|
||||
let error = Arc::new(io::Error::from(io::ErrorKind::ConnectionReset));
|
||||
|
|
|
|||
Loading…
Reference in New Issue