Skip to content

Conversation

@asutoshpalai
Copy link
Contributor

@asutoshpalai asutoshpalai commented Oct 17, 2017

The LevelDB index of bitcoind contains details about the height of the block, file and offset of the block in the file. This can be used to extract the block ordered by height.

Fixes #13

@itoonx
Copy link

itoonx commented Oct 22, 2017

Awesome

@brannondorsey
Copy link
Contributor

In it's current state, I am finding that this implementation seems to corrupt the .bitcoin/blocks/index such that it requires bitcoin-core to re-index the entire blockchain each time this code is run. Its a great approach to the solution, but I just want to warn folks who might come across it that this may occur.

@alecalve
Copy link
Owner

I tried this branch and some variant of it and both resulted in the corruption of the index. bitcoind's error message (LevelDB read failure: Corruption: corrupted compressed block contents) indicates some issue with Snappy compression.

I tried using plyvel 1.0.4 which should have support for snappy, but I got the same error.

A simple fix to this issue is to require to copy the index to a different directory than blocks/index and use this copy to read blocks position. While it would most likely work, it makes using this feature cumbersome.

@asutoshpalai
Copy link
Contributor Author

After @brannondorsey reported it, I tried to look into it. When I was working on this, my Bitcoin blockchain was offline. Since I didn't turn the daemon back on, I didn't face this issue.

Thanks, @alecalve for looking into this. I was hoping shifting to a modern LevelDB library would have fixed this issue. Unfortunately, I have lost access to the bitcoin blockchain server I was using and currently don't possess the capability to set up one in near future. This makes me incapable of working on this issue.

If anyone wants to continue this and find some fix in this or any other PR/fork, I will be glad. I hope this work doesn't get wasted.

@brannondorsey
Copy link
Contributor

Perhaps this is related to this issue. They have the same problem with snappy compression corrupting the LevelDB chainstate. It seems that opening the LevelDB database without snappy compression worked for them.

# Open the LevelDB
db = plyvel.DB(".bitcoin/chainstate", compression=None)

@alecalve, when you ran your tests with Plyvel, did you try disabling snappy compression?

@alecalve
Copy link
Owner

I didn't, I ran it with the defaults args, which make use of snappy.

@brannondorsey
Copy link
Contributor

Ok, I'm going to take another look at this.

brannondorsey added a commit to brangerbriz/python-bitcoin-blockchain-parser that referenced this pull request Feb 23, 2018
@alecalve alecalve merged commit 78a78db into alecalve:master Feb 26, 2018
@asutoshpalai
Copy link
Contributor Author

My sincere gratitude to @alecalve and @brannondorsey for their efforts in making this work!

olaf11071107 added a commit to olaf11071107/python-bitcoin-blockchain-parser that referenced this pull request Nov 19, 2024
Moe5211 pushed a commit to Moe5211/python-bitcoin-blockchain-parser that referenced this pull request Jan 17, 2025
rudyapollo added a commit to rudyapollo/python-bitcoin-blockchain-parser that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants