network_pex_query_hosts(struct network *net)
{
struct network_host *host;
+ uint64_t now;
int rv = rand();
int hosts = 0;
int i;
if (!hosts)
return;
+ now = unet_gettime();
rv %= net->hosts.count;
for (i = 0; i < 2; i++) {
avl_for_each_element(&net->hosts, host, node) {
if (host == net->net_config.local_host)
continue;
- if (!peer->state.connected)
+ if (!peer->state.connected ||
+ peer->state.last_query_sent + 15 >= now)
continue;
D_PEER(net, peer, "send query for %d hosts", hosts);
switch (ev) {
case PEX_EV_HANDSHAKE:
+ peer->state.last_query_sent = 0;
pex_send_hello(net, peer);
if (net->config.type == NETWORK_TYPE_DYNAMIC)
network_pex_send_update_request(net, peer, NULL);