2
I'm playing around with connecting my node to another one of my nodes to see how many incoming connections I can handle.
Whenever I add node A from node B with bitcoin-cli addnode 1.1.1.1 add after the first time, I get:
error code: -23
error message:
Error: Node already added
Is there a way around this? Can I edit the source code somehow to allow multiple connections between the same nodes? Presumably I would only have to edit the code for the sending node, not the receiving node, since I think the receiving node has to be able to accept connections from what appear to be the same IP and port because of NATS? The alternative is to run many instances of bitcoind in pruned mode which would work I guess, but it's not ideal obviously
I'm curious, why do you want to do this? – chytrik – 2018-12-04T22:24:32.667
To see how many incoming connections my nodes can handle. :) – user46871 – 2018-12-04T22:28:50.203
Max number of incoming connections is part of config. – James C. – 2018-12-04T22:38:47.033
@JamesC. I know but I want to allow one node (A) to establish many
outgoingconnections to the same node (B) – user46871 – 2018-12-04T22:40:58.957Ok, it is not allowed as you already mentioned. The same p2p communication will be repeated, so multiple channels are redundant. If a node propagates a new tx or header, it will announce it to all channels. But if you still want to do it, I think the peer is id’ed by IP in version msg, so you would have to tweak the sourcecode to broadcast a different address for each channel, or accept identical IP on multiple inbound connections. – James C. – 2018-12-04T22:48:38.690
Wouldn't changing the IP in the msg make data sent back to (A) go to the wrong IP address? – user46871 – 2018-12-04T23:00:53.537
No, its separate from the actual tcp connection, which is why a peer may send a different address sitting behind a nat than is seen by receiving peer ofthe tcp connection. – James C. – 2018-12-04T23:06:19.237
@JamesC. I see, thanks! I can't mark your comment as an answer for some reason though Also, if anyone could point me to where in the code I should edit, that would be awesome haha – user46871 – 2018-12-05T00:16:47.650
To find the point in the source code you want to change, the best thing to do is to search for the error string you receive ("Node already added").
However, for your purpose (to see how many connections you can handle) I'd rather run multiple nodes on the same machine of B. You can easily do it by using the '-datadir' option and using different ports (keeping the same IP).
The only limit there could be is the number of peers from the same subnet you can connect to, which is limited to 1 in Bitcoin Core. But maybe this is not the case with manual connections like 'addnode'. – FedFranzoni – 2018-12-19T11:04:01.787