| 812 | } |
| 813 | |
| 814 | static void PushAddress(Peer& peer, const CAddress& addr, FastRandomContext& insecure_rand) |
| 815 | { |
| 816 | // Known checking here is only to save space from duplicates. |
| 817 | // Before sending, we'll filter it again for known addresses that were |
| 818 | // added after addresses were pushed. |
| 819 | assert(peer.m_addr_known); |
| 820 | if (addr.IsValid() && !peer.m_addr_known->contains(addr.GetKey()) && IsAddrCompatible(peer, addr)) { |
| 821 | if (peer.m_addrs_to_send.size() >= MAX_ADDR_TO_SEND) { |
| 822 | peer.m_addrs_to_send[insecure_rand.randrange(peer.m_addrs_to_send.size())] = addr; |
| 823 | } else { |
| 824 | peer.m_addrs_to_send.push_back(addr); |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUSIVE_LOCKS_REQUIRED(cs_main) |
| 830 | { |