Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: disckjet on December 19, 2013, 05:59:20 PM



Title: How many addresses are sent in response to a getaddr message?
Post by: disckjet on December 19, 2013, 05:59:20 PM
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:

Code:
// 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 https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery (https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery):

Quote
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...

Quote
[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?