5

I've been trying to determine the number of addresses a node sends when it receives a getaddr message but I'm a little confused.

On one hand, on addrman.h/.cpp I can see that:

// the maximum percentage of nodes to return in a getaddr call
#define ADDRMAN_GETADDR_MAX_PCT 23

// the maximum number of nodes to return in a getaddr call
#define ADDRMAN_GETADDR_MAX 2500

[...]

int nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100;
if (nNodes > ADDRMAN_GETADDR_MAX)
    nNodes = ADDRMAN_GETADDR_MAX;

So it seems that the number of addresses sent is the smaller of the two conditions, namely, 23% of the (active known) nodes or 2500 nodes.

But on the other hand, from the bitcoin wiki:

The getaddr message sends a request to a node asking for information about known active peers to help with identifying potential nodes in the network. The response to receiving this message is to transmit an addr message with one or more peers from a database of known active peers.

...and...

[About addr messages] If the sender sent over 1000 addresses, they are all ignored.

So, why does a node try to send 2500 addresses if the receiver is going to discard them? Why not sending at most 1000 addresses?

2 Answers 2

1

The result from CAddrMan::GetAddr() is fed to CNode::PushAddress, which filters out addresses the peer already has, and inserts them in a temporary buffer of up to 1000 addresses.

Later, in SendMessages(), the contents of that buffer is sent out periodically.

0

According to the wiki, it seems like these are "Ongoing "addr" advertisements" thus unsolicited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.