mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-21 01:11:43 +02:00
[net processing] Take NodeId instead of CNode* as originator for RelayAddress()
This makes the following commit easier.
This commit is contained in:
parent
539e4eec63
commit
86acc96469
@ -1490,13 +1490,13 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid, const uint256& wtxid
|
|||||||
* address. So within 24h we will likely relay a given address once. This is to
|
* address. So within 24h we will likely relay a given address once. This is to
|
||||||
* prevent a peer from unjustly giving their address better propagation by sending
|
* prevent a peer from unjustly giving their address better propagation by sending
|
||||||
* it to us repeatedly.
|
* it to us repeatedly.
|
||||||
* @param[in] originator The peer that sent us the address. We don't want to relay it back.
|
* @param[in] originator The id of the peer that sent us the address. We don't want to relay it back.
|
||||||
* @param[in] addr Address to relay.
|
* @param[in] addr Address to relay.
|
||||||
* @param[in] fReachable Whether the address' network is reachable. We relay unreachable
|
* @param[in] fReachable Whether the address' network is reachable. We relay unreachable
|
||||||
* addresses less.
|
* addresses less.
|
||||||
* @param[in] connman Connection manager to choose nodes to relay to.
|
* @param[in] connman Connection manager to choose nodes to relay to.
|
||||||
*/
|
*/
|
||||||
static void RelayAddress(const CNode& originator,
|
static void RelayAddress(NodeId originator,
|
||||||
const CAddress& addr,
|
const CAddress& addr,
|
||||||
bool fReachable,
|
bool fReachable,
|
||||||
const CConnman& connman)
|
const CConnman& connman)
|
||||||
@ -1516,8 +1516,8 @@ static void RelayAddress(const CNode& originator,
|
|||||||
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
|
std::array<std::pair<uint64_t, CNode*>,2> best{{{0, nullptr}, {0, nullptr}}};
|
||||||
assert(nRelayNodes <= best.size());
|
assert(nRelayNodes <= best.size());
|
||||||
|
|
||||||
auto sortfunc = [&best, &hasher, nRelayNodes, &originator, &addr](CNode* pnode) {
|
auto sortfunc = [&best, &hasher, nRelayNodes, originator, &addr](CNode* pnode) {
|
||||||
if (pnode->RelayAddrsWithConn() && pnode != &originator && pnode->IsAddrCompatible(addr)) {
|
if (pnode->RelayAddrsWithConn() && pnode->GetId() != originator && pnode->IsAddrCompatible(addr)) {
|
||||||
uint64_t hashKey = CSipHasher(hasher).Write(pnode->GetId()).Finalize();
|
uint64_t hashKey = CSipHasher(hasher).Write(pnode->GetId()).Finalize();
|
||||||
for (unsigned int i = 0; i < nRelayNodes; i++) {
|
for (unsigned int i = 0; i < nRelayNodes; i++) {
|
||||||
if (hashKey > best[i].first) {
|
if (hashKey > best[i].first) {
|
||||||
@ -2683,7 +2683,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
if (addr.nTime > nSince && !pfrom.fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())
|
if (addr.nTime > nSince && !pfrom.fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())
|
||||||
{
|
{
|
||||||
// Relay to a limited number of other nodes
|
// Relay to a limited number of other nodes
|
||||||
RelayAddress(pfrom, addr, fReachable, m_connman);
|
RelayAddress(pfrom.GetId(), addr, fReachable, m_connman);
|
||||||
}
|
}
|
||||||
// Do not store addresses outside our network
|
// Do not store addresses outside our network
|
||||||
if (fReachable)
|
if (fReachable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user