| 1137 | } |
| 1138 | |
| 1139 | void PeerManagerImpl::PushAddress(Peer& peer, const CAddress& addr) |
| 1140 | { |
| 1141 | // Known checking here is only to save space from duplicates. |
| 1142 | // Before sending, we'll filter it again for known addresses that were |
| 1143 | // added after addresses were pushed. |
| 1144 | assert(peer.m_addr_known); |
| 1145 | if (addr.IsValid() && !peer.m_addr_known->contains(addr.GetKey()) && IsAddrCompatible(peer, addr)) { |
| 1146 | if (peer.m_addrs_to_send.size() >= MAX_ADDR_TO_SEND) { |
| 1147 | peer.m_addrs_to_send[m_rng.randrange(peer.m_addrs_to_send.size())] = addr; |
| 1148 | } else { |
| 1149 | peer.m_addrs_to_send.push_back(addr); |
| 1150 | } |
| 1151 | } |
| 1152 | } |
| 1153 | |
| 1154 | static void AddKnownTx(Peer& peer, const uint256& hash) |
| 1155 | { |