Description
openedon Oct 19, 2021
Motivation
When Zebra starts up, the crawler task tries to dial peerset_initial_target_size
peers. This is in addition to the peerset_initial_target_size
peers from the initial seed peer connection limit.
But we only want peerset_initial_target_size
initial peers, not peerset_initial_target_size * 2
initial peers. In PR #2944, this extra demand gets dropped, but it's a small waste of CPU and RAM.
Suggested Design
Initialize the peer connection count demand_tx
in peer_set::initialize
based on the number of connections made in add_initial_peers
.
Edge Cases
The initial peer limit counts connection attempts. But the connection limit is for open connections. So we have to count the right thing here.
We should make sure the calculation doesn't underflow and panic.
Related Work
These tickets might modify the same functions as this ticket: