Per-network bitcoin.conf files #9374

issue rebroad openend this issue on December 19, 2016
  1. rebroad commented at 3:30 am on December 19, 2016: contributor

    When running with the -testnet option, I would expect the bitcoin.conf file in the testnet3 directory to be used, yet it uses the mainnet config file instead, yet the debug.log indicates the datadir is the testnet3 dir:-

    02016-12-19 03:08:58.629380 Using data directory /home/rebroad/.bitcoin/testnet3
    12016-12-19 03:08:58.629453 Using config file /home/rebroad/.bitcoin/bitcoin.conf
    
  2. rebroad renamed this:
    -datadir seemingly ignored for config file
    wrong config file used for -testnet
    on Dec 19, 2016
  3. laanwj commented at 7:56 am on December 19, 2016: member

    There has never been any functionality to read per-network config files. Config file is always read from the root of the data directory.

    It could be useful. However this is more complicated to implement than you’d think, not only because of backward compatiblity, but because bitcoin.conf in the data directory can specify the network to use e.g. testnet=1 or regtest=1. This is used by the tests. It is also useful in the case of specifying a .conf file with -conf that is outside any data directory (used for system-wide setups).

  4. laanwj renamed this:
    wrong config file used for -testnet
    Per-network bitcoin.conf files
    on Dec 19, 2016
  5. laanwj commented at 8:29 am on December 19, 2016: member

    One idea of doing this is to keep bitcoin.conf as global configuration file, then after that is loaded (and thus the network determined) load an optional per-network configuration that can override these parameters, e.g.:

    • ${DATADIR}/network.conf
    • ${DATADIR}/testnet3/network.conf
    • ${DATADIR}/regtest/network.conf
  6. laanwj added the label Feature on Dec 20, 2016
  7. rebroad commented at 1:39 pm on December 20, 2016: contributor
    @laanwj Hmmm. sounds messy; for example, how would ‘addnode=’s be overridden if there were none mentioned in the testnet config file? I often want to add nodes for the mainnet configuration but not for the testnet configuration. For backwards compatibility (which I agree is important), I’d suggest that if the conf file for testnet or regtest does not exist then it defaults back to the mainnet config file. Unless, this is what you meant, in which case, I agree
  8. laanwj commented at 1:44 pm on December 20, 2016: member

    My proposal above allows for full flexibility here.

    Bitcoin Core will look, in a second configuration stage, for a network.conf in the per-network data directory and process this.

    If you wanted to add testnet-specific addnodes you’d put these in ${DATADIR}/testnet3/network.conf. If you want to add mainnet-specific addnotes you’d put these in ${DATADIR}/network.conf. In the global ${DATADIR}/bitcoin.conf you’d not put any addnodes, you can put configuration there that you want to always apply (such as changing your uacomment, debug levels, proxy config, etc).

  9. morcos commented at 2:23 pm on December 20, 2016: member
    @laanwj +1 for network.conf idea
  10. rebroad commented at 2:41 pm on December 20, 2016: contributor
    I suspect, I would just prefer to use one .conf file per network, so ideally this would allow me to abandon the bitcoin.conf file, and just use network.conf files.
  11. jonasschnelli commented at 2:45 pm on December 20, 2016: contributor
    +1 for @laanwj network.conf idea. @rebroad: your solution would no longer be downward compatible (by dropping support for the network selection in bitcoin.conf).
  12. rebroad commented at 2:51 pm on December 20, 2016: contributor
    @jonasschnelli I wasn’t proposing to drop support for anything in the bitcoin.conf file. My solution sounds the same as @laanwj’s except that I would have kept the conf file as bitcoin.conf and not created a new config file.
  13. jonasschnelli commented at 3:14 pm on December 20, 2016: contributor
    @rebroad: but how would it be practical to switch the network (regtest=1, testnet=1) if you remove the general bitcoin.conf file?
  14. btcdrak commented at 3:29 pm on December 20, 2016: contributor
    +1 for @laanwj network.conf idea.
  15. laanwj commented at 4:53 pm on December 20, 2016: member

    I suspect, I would just prefer to use one .conf file per network, so ideally this would allow me to abandon the bitcoin.conf file, and just use network.conf files.

    Yes, network.conf file should be looked for irrespective of whether bitcoin.conf exists (that’s also easiest to implement).

    @rebroad: but how would it be practical to switch the network (regtest=1, testnet=1) if you remove the general bitcoin.conf file?

    He chooses to not use that functionality - but for any solution here it should still be supported - those are orthogonal things :)

  16. gmaxwell commented at 0:10 am on December 21, 2016: contributor
    I often intentionally use the same config files on mainnet and testnet. The two stage thing would be dandy.
  17. rebroad referenced this in commit ff9a1f9907 on Dec 21, 2016
  18. rebroad referenced this in commit fcfdc57b9c on Dec 21, 2016
  19. rebroad referenced this in commit 76bb770eb8 on Dec 21, 2016
  20. rebroad referenced this in commit ce70d410af on Dec 21, 2016
  21. rebroad referenced this in commit c2d49f752e on Dec 23, 2016
  22. rebroad referenced this in commit 5fd466a43b on Dec 23, 2016
  23. rebroad referenced this in commit b1a75b851e on Dec 23, 2016
  24. rebroad referenced this in commit 4a81f9044c on Dec 24, 2016
  25. rebroad referenced this in commit bf9a98d3be on Dec 24, 2016
  26. rebroad referenced this in commit 04441f04dd on Dec 26, 2016
  27. rebroad referenced this in commit 7106f10eb8 on Dec 26, 2016
  28. rebroad referenced this in commit cb040da411 on Dec 26, 2016
  29. rebroad referenced this in commit 7008336229 on Dec 26, 2016
  30. rebroad referenced this in commit 27b14c0f6d on Dec 27, 2016
  31. rebroad commented at 4:01 am on December 27, 2016: contributor
    I’m going to try and raise an issue with github regarding these message above (they are produced whenever I re-push a branch containing this commit).
  32. rebroad referenced this in commit bfd6974c40 on Dec 27, 2016
  33. rebroad referenced this in commit 81b987163b on Dec 28, 2016
  34. rebroad referenced this in commit cef90d1765 on Dec 28, 2016
  35. rebroad referenced this in commit be6db67f4e on Dec 28, 2016
  36. rebroad referenced this in commit d4ff270b26 on Dec 28, 2016
  37. rebroad commented at 10:09 am on December 28, 2016: contributor
    rebased following #9243
  38. jnewbery commented at 2:37 pm on May 9, 2018: member
    Closed by #11862 and #10267. It is now possible to create network-specific sections or entire config files.
  39. jnewbery closed this on May 9, 2018

  40. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me