Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Oct 5, 2019

This PR:

  • simplifies path argument (datadir/blocks/index) for CBlockTreeDB constructor
  • does not change behavior as GetBlocksDir() with unset "-blocksdir" returns the same path
  • improves code readability

This commit does not change behavior as GetBlocksDir() with unset 
"-blocksdir" returns the same path.
@hebasto
Copy link
Member Author

hebasto commented Oct 5, 2019

ping @jonasschnelli

@maflcko
Copy link
Member

maflcko commented Oct 5, 2019

Needs test/functional/feature_blocksdir.py extended to show the change in behavior

@hebasto
Copy link
Member Author

hebasto commented Oct 5, 2019

Needs test/functional/feature_blocksdir.py extended to show the change in behavior

What "the change in behavior"? This PR does not introduce any change in behavior.

@maflcko
Copy link
Member

maflcko commented Oct 5, 2019

ACK c2bb391

}

CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(gArgs.IsArgSet("-blocksdir") ? GetDataDir() / "blocks" / "index" : GetBlocksDir() / "index", nCacheSize, fMemory, fWipe) {
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you pick the wrong side here?
Shouldn't this be GetBlocksDir() / "index" instead? Otherwise it seems it's losing the functionality of -blocksdir.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you pick the wrong side here?

This PR does not introduce any change in behavior.

Shouldn't this be GetBlocksDir() / "index" instead? Otherwise it seems it's losing the functionality of -blocksdir.

-blocksdir allows to place raw blocks to a large and slow HDD, while it leaves blockindex on a fast SSD.

Ref: #12653

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. Your'ee right. Thanks for the simplification, that's quite sneaky. I was reading it the wrong way around.

In the future let's review more carefully for people to use an explicit if() statement instead of cramming this kind of logic into an initializer.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c2bb391.

@laanwj
Copy link
Member

laanwj commented Oct 8, 2019

ACK c2bb391

laanwj added a commit that referenced this pull request Oct 8, 2019
c2bb391 util: Simplify path argument for CBlockTreeDB ctor (Hennadii Stepanov)

Pull request description:

  This PR:
  - simplifies path argument (`datadir/blocks/index`) for `CBlockTreeDB`  constructor
  - does not change behavior as `GetBlocksDir()` with unset "-blocksdir" returns the same path
  - improves code readability

ACKs for top commit:
  MarcoFalke:
    ACK c2bb391
  laanwj:
    ACK c2bb391
  promag:
    ACK c2bb391.

Tree-SHA512: 646a0a3a31e2f419b05f696cbdfb7d8987f1d89ec0797b72464ae05680fd5f95f6469be0ea5b56f772434c49d48504cd9cf9760c05d4054d11349d502e157ee2
@laanwj laanwj merged commit c2bb391 into bitcoin:master Oct 8, 2019
@hebasto hebasto deleted the 20191005-blocks-index branch October 8, 2019 09:59
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 8, 2019
c2bb391 util: Simplify path argument for CBlockTreeDB ctor (Hennadii Stepanov)

Pull request description:

  This PR:
  - simplifies path argument (`datadir/blocks/index`) for `CBlockTreeDB`  constructor
  - does not change behavior as `GetBlocksDir()` with unset "-blocksdir" returns the same path
  - improves code readability

ACKs for top commit:
  MarcoFalke:
    ACK c2bb391
  laanwj:
    ACK c2bb391
  promag:
    ACK c2bb391.

Tree-SHA512: 646a0a3a31e2f419b05f696cbdfb7d8987f1d89ec0797b72464ae05680fd5f95f6469be0ea5b56f772434c49d48504cd9cf9760c05d4054d11349d502e157ee2
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 26, 2020
Summary:
> This PR:
>
> - simplifies path argument (datadir/blocks/index) for CBlockTreeDB constructor
> - does not change behavior as GetBlocksDir() with unset "-blocksdir" returns the same path
> - improves code readability

This is a backport of Core [[bitcoin/bitcoin#17059 | PR17059]]

Test Plan: `ninja all check-all`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8119
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request May 1, 2021
… Allow to specify blocks storage directory

b0e0d55 doc: add '-blocksdir' option to release-notes (furszy)
50e66c2 Turn TryCreateDirectory() into TryCreateDirectories() (Marko Bencun)
035d3c2 util: Simplify path argument for CBlockTreeDB ctor (Hennadii Stepanov)
a571d24 Fail if either disk space check fails (Ben Woosley)
e567003 Improve blocksdir functional test. (Hennadii Stepanov)
ff0ae45 Make blockdir always net specific (Hennadii Stepanov)
13a4119 doc: Clarify -blocksdir usage (Daniel McNally)
a4ff899 -blocksdir: keep blockindex leveldb database in datadir (Jonas Schnelli)
3054076 QA: Add -blocksdir test (Jonas Schnelli)
39b8127 Allow to optional specify the directory for the blocks storage (Jonas Schnelli)
a821b0b BugFix: Move TestingSetup::ECCVerifyHandle member to BasicTestingSetup. (furszy)
5844452 Remove unneeded GetTempPath, only use temp directory in unit tests (furszy)
7fc893b [Test] BasicTestingSetup constructor receiving the network param. (furszy)

Pull request description:

  Grouped two different, zero risk, modifications here to not have to create two/three small and straightforward PRs:

  #### 1) Unit Tests:

  * Fixing basic unit test setup issue, was not initializing the libsecp256k1 context. Thus why we have been forced to use the extended unit testing setup for almost every test case (which includes CConnman, scheduler, validation interface, etc.. that are not needed so often).
  * Refactor: `BasicTestingSetup` receiving the network in the constructor.

  #### 2) Back ported the ability to specify a custom directory for the blocks storage.

  > Since the actual block files taking up more and more space, it may be desirable to have them stored in a different location then the data directory (use case: SSD for chainstate, etc., HD for blocks).
  This PR adds a -blocksdir option that allows one to keep the blockfiles external from the data directory (instead of creating symlinks).

  * bitcoin#9895.
  * bitcoin#12653.
  * bitcoin#14364.
  * bitcoin#14409.
  * bitcoin#15124.
  * bitcoin#17059.

ACKs for top commit:
  Fuzzbawls:
    re-ACK b0e0d55
  random-zebra:
    utACK b0e0d55 and merging...

Tree-SHA512: 289e5b826c8fc23a5933a5b30e6c043f82bad827b10f3093cbc5869a9e278d7ad0a325dd19b5ad3c97f23a3dee69f5b0bee3869e486eeed5e8d8342a39919cf5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Nov 3, 2021
c2bb391 util: Simplify path argument for CBlockTreeDB ctor (Hennadii Stepanov)

Pull request description:

  This PR:
  - simplifies path argument (`datadir/blocks/index`) for `CBlockTreeDB`  constructor
  - does not change behavior as `GetBlocksDir()` with unset "-blocksdir" returns the same path
  - improves code readability

ACKs for top commit:
  MarcoFalke:
    ACK c2bb391
  laanwj:
    ACK c2bb391
  promag:
    ACK c2bb391.

Tree-SHA512: 646a0a3a31e2f419b05f696cbdfb7d8987f1d89ec0797b72464ae05680fd5f95f6469be0ea5b56f772434c49d48504cd9cf9760c05d4054d11349d502e157ee2
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
c2bb391 util: Simplify path argument for CBlockTreeDB ctor (Hennadii Stepanov)

Pull request description:

  This PR:
  - simplifies path argument (`datadir/blocks/index`) for `CBlockTreeDB`  constructor
  - does not change behavior as `GetBlocksDir()` with unset "-blocksdir" returns the same path
  - improves code readability

ACKs for top commit:
  MarcoFalke:
    ACK c2bb391
  laanwj:
    ACK c2bb391
  promag:
    ACK c2bb391.

Tree-SHA512: 646a0a3a31e2f419b05f696cbdfb7d8987f1d89ec0797b72464ae05680fd5f95f6469be0ea5b56f772434c49d48504cd9cf9760c05d4054d11349d502e157ee2
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants