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

0
40


I had tried few things when reviewed this PR: https://github.com/bitcoin/bitcoin/pull/22013

While reviewing PR https://github.com/bitcoin/bitcoin/pull/22651, 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="127.0.0.1:9051" -proxy='127.0.0.1:9050' -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="127.0.0.1:18333" -torcontrol="127.0.0.1:9051" -proxy='127.0.0.1:9050' -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=127.0.0.1:7656 -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