Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -chainstatedir and -blocksdir in bitcoin.conf #14595

Closed
Janaka-Steph opened this Issue Oct 28, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@Janaka-Steph
Copy link

Janaka-Steph commented Oct 28, 2018

Hello!

I am running a bitcoin core node on my macbook with datadir on an external hard drive. The sync performance wasn't great so I searched to improve it and I found this thread #10647 (comment)

Peter is suggesting to keep the chainstate on internal disk but only moving blocks on external disk. My question is, is there some plans to let user the possibility to specify that in the config file instead of creating symlink, having chainstatedir and blocksdir parameters in addition to datadir?

Thank you

@hebasto

This comment has been minimized.

Copy link
Member

hebasto commented Nov 3, 2018

-blocksdir option has been already supported by the command line and/or bitcoin.conf file.
See: #12653

@Janaka-Steph

This comment has been minimized.

Copy link
Author

Janaka-Steph commented Nov 5, 2018

spec: Bitcoin 0.17.0, Mac OSX

@hebasto Oh ok I didn't know that, thank you.
However I tried to add blocksdir to my config file and it is not taken into account. I first tried to add blocksdir under sections [main] and [test]. This doesn't work. And having a global blocksdir doesn't work either.

I have an additional issue with regtest. I want to keep the default data directory but when I run bitcoind, it will create an empty blocks folder at the root of the bitcoin directory in addition to a blocks folder in the regtest directory. It seems that bitcoind in regtest will first search for a blocks dir as if it was on mainnet. It forces me to plug my external hard drive even if I work on regtest.
Specifying datadir or blocksdir in [regtest] to avoid this unwanted behavior doesn't work.

@hebasto

This comment has been minimized.

Copy link
Member

hebasto commented Nov 5, 2018

@Janaka-Steph

However I tried to add blocksdir to my config file and it is not taken into account. I first tried to add blocksdir under sections [main] and [test]. This doesn't work. And having a global blocksdir doesn't work either.

Can you provide your bitcoin.conf file here?

I have an additional issue with regtest. I want to keep the default data directory but when I run bitcoind, it will create an empty blocks folder at the root of the bitcoin directory in addition to a blocks folder in the regtest directory.

The #14409 patch fixes this issue.

@Janaka-Steph

This comment has been minimized.

Copy link
Author

Janaka-Steph commented Nov 5, 2018

Here is my bitcoin conf file. blocksdir is commented. I tried different things but can't have it working.

# This config should be placed in following path on Mac OSX:
# $HOME/Library/Application Support/Bitcoin/bitcoin.conf

###
#[core]

#regtest=1
testnet=1

# Maintain a full transaction index, used by the getrawtransaction rpc call.
txindex=1

# Specify a non-default location to store blockchain and other data.
# Default location on Mac OSX: $HOME/Library/Application Support/Bitcoin
# Having chainstate on external HD hurts performance badly, see https://github.com/bitcoin/bitcoin/issues/10647#issuecomment-312466993
# datadir=/Volumes/Blockchains/Bitcoin

# Configuration file location
# conf=/Users/steph/Library/Application Support/Bitcoin/bitcoin.conf

# Set database cache size in megabytes; machines sync faster with a larger cache
# Recommend setting as high as possible based upon machine's available RAM
dbcache=10000

# Append comment to the user agent string
uacomment=fuckTheBanks


###
#[zeromq]
# Enable publishing of block hashes to <address>.
zmqpubhashblock=tcp://127.0.0.1:30001

# Enable publishing of transaction hashes to <address>.
zmqpubhashtx=tcp://127.0.0.1:30001



###
#[debug]
# Categories: net, tor, mempool, http, bench, zmq, db, rpc, estimatefee, addrman, selectcoins, reindex, cmpctblock, rand, prune, proxy, mempoolrej, libevent, coindb, qt, leveldb
debug=1
# Log IP Addresses in debug output.
logips=1


# [network]
# Automatically create Tor hidden service
# listenonion=0
# Use UPnP to map the listening port
upnp=1


###
#[rpc]
# Accept command line and JSON-RPC commands.
server=1

# Accept public REST requests.
rest=1

# Secure the JSON-RPC api. Deprecated method, use rpcauth instead
#rpcuser=user
#If no rpcpassword is set, rpc cookie auth is sought
#rpcpassword=lulz

# Location of the RPC auth cookie
#rpccookiefile=/Users/steph/Library/Application\ Support/Bitcoin/regtest/.cookie

# Username and hashed password for JSON-RPC connections. <USERNAME>:<SALT>$<HASH>
# RPC clients connect using rpcuser=<USERNAME>/rpcpassword=<PASSWORD> arguments.
# You can generate this value with the ./share/rpcauth/rpcauth.py script in the Bitcoin Core repository
# rpcauth=stephane:c2aab19c89911bdeae44792ad23a8edb$e1057aa437fb1b6466de687f697b6ba8ea6fd3807b9b5bf38e972771ad4c6ce2

# Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times.
#rpcallowip=127.0.0.1


###
# [wallet]
# Send transactions with full-RBF (bip125-replaceable), activated by default. Use bumpfee "txid" to replace a tx.
walletrbf=1

#disablewallet=1



###
# Network specific sections
# https://bitcoin.org/en/release/v0.17.0#configuration-sections-for-testnet-and-regtest
[main]
#blocksdir=/Volumes/Blockchains/Bitcoin

# Bitcoin network protocol listen port (default 8333)
#port=8333

# RPC connection port (default 8332)
#rpcport=8332

#mempoolsize=300



[test]
#blocksdir=/Volumes/Blockchains/Bitcoin

# Bitcoin network protocol listen port (default 18333)
port=18401

# RPC connection port (default 18332)
#rpcport=18332

#mempoolsize=100

# Fees (in BTC/kB) smaller than this are considered zero fee for transaction creation (default: 0.00001)
mintxfee=0.001

# Fee (in BTC/kB) to add to transactions you send (default: 0.00)
#paytxfee=0.001

# If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6)
txconfirmtarget=1

# Specify a non-default location to store wallet data.
# walletdir=/Users/steph/Library/Application Support/Bitcoin/testnet3/wallet1



[regtest]
#blocksdir=/Volumes/Blockchains/Bitcoin

# Bitcoin network protocol listen port (default 18444)
#port=18444

# RPC connection port (default 18443)
#rpcport=18443

# Location of the RPC auth cookie
# rpccookiefile=/Users/steph/Desktop/Bitcoin/Regtest_Server/.cookie

# Set the depth of the work queue to service RPC calls
rpcworkqueue=32

#mempoolsize=20
@hebasto

This comment has been minimized.

Copy link
Member

hebasto commented Nov 30, 2018

@Janaka-Steph
I've tested your config file on MacOS 10.13.6:

...
testnet=1
...
[test]
#blocksdir=/Volumes/Blockchains/Bitcoin
blocksdir=/Users/hebasto/Desktop/BLOCKS
...

It works as expected for me:

$ ls /Users/hebasto/Desktop/BLOCKS/testnet3/
blocks
@Janaka-Steph

This comment has been minimized.

Copy link
Author

Janaka-Steph commented Jan 11, 2019

Hello,
Sorry for the delay. I have tested again the blocksdir option in conf file test section, on Mac 10.14.2 and Core 0.17.1, and it works. Blocks are written on my external HD.

laanwj added a commit that referenced this issue Jan 16, 2019

Merge #14409: utils and libraries: Make 'blocksdir' always net specific
e4a0c35 Improve blocksdir functional test. (Hennadii Stepanov)
c3f1821 Make blockdir always net specific (Hennadii Stepanov)

Pull request description:

  The blocks directory is net specific by definition.

  Also this prevents the side effect of calling `GetBlocksDir(false)` in the non-mainnet environment.
  Currently a new node creates an unused `blocks\` directory in the root of the data directory when `-testnet` or `-regtest` is specified.

  Refs:
  - #12653
  - #12653 (comment) by @laanwj
  - #14595 (comment)

Tree-SHA512: c9957a68a4a200ebd2010823a56db7e61563afedcb7c9828e86b13f3af2990e07854b622c1f3374756f94574acb3ea32de7d2a399eef6c0623f0e11265155627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.