- if (changed || peers->npeers!=1)
- transport_peers_debug(st,peers,m, 1,addr,0);
- transport_peers_expire(st, peers);
+ if (naddrs==1 && peers->npeers>=1 &&
+ transport_addrs_equal(&addrs[0], &peers->peers[0].addr)) {
+ /* optimisation, also avoids debug for trivial updates */
+ peers->peers[0].last = *tv_now;
+ return;
+ }
+
+ int old_npeers=peers->npeers;
+ transport_peers old_peers[old_npeers];
+ memcpy(old_peers,peers->peers,sizeof(old_npeers));
+
+ peers->npeers=0;
+ int i;
+ for (i=0; i<naddrs; i++) {
+ if (!transport_peer_record_one(st,peers, &addrs[i], tv_now))
+ break;
+ }
+ for (i=0; i<old_npeers; i++) {
+ const transport_peer *old=&old_peers->peers[i];
+ if (!transport_peer_record_one(st,peers, &old->addr, &old->last))
+ break;
+ }
+
+ transport_peers_debug(st,peers,m, naddrs,addrs,0);