bitcoin core – When exactly are peers saved in peers.dat file?


I had tried few things when reviewed this PR:

While reviewing PR, I was expecting 1 peer to be saved in peers.dat using the below steps:

  1. Run Node 1:
bitcoind -port=18333 -rpcport=18222 -datadir="/home/user/node1" -regtest=1 -listen=1 -server=1 -debug=net -rpcuser=user1 -rpcpassword=password1 -torcontrol="" -proxy='' -onlynet=onion
  1. Run Node 2:
bitcoind -port=18777 -rpcport=18666 -datadir="/home/user/node2" -regtest=1 -listen=1 -server=1 -debug=net -rpcuser=user2 -rpcpassword=password2 -addnode="" -torcontrol="" -proxy='' -onlynet=onion
  1. Stop Node 1 and 2:
bitcoin-cli -rpcport=18222 -rpcuser=user1 -rpcpassword=password1 stop
bitcoin-cli -rpcport=18666 -rpcuser=user2 -rpcpassword=password2 stop
  1. Restart Node 2 with different config (onlynet=i2p and no proxy):
bitcoind -port=18777 -rpcport=18666 -datadir="/home/user/node2" -regtest=1 -listen=1 -server=1 -debug=net -rpcuser=user2 -rpcpassword=password2 -i2psam= -onlynet=i2p

But nothing was saved in peers.dat according to logs. So I had to use addpeeraddress for the test which I guess does the same thing. So if node 1 is added as outbound connection in node 2, shouldn’t this be saved in peers.dat? How does it work in case of testnet or mainnet?

Source link

Leave a reply