6

I know that chaindata folder (on Mac OS X) stores the state as key/value database. But how is a block stored? Are transactions also stored as key/value pairs? If yes, how to identify which files belong to transactions and which files belong to state? I have a bunch of levelDB files 'ldb' under chaindata and I have no idea how to probe them, say using python levelDB bindings.

This question does ask a bit about the blockchain, however the answer does not particularly refer to how blocks are stored.

EDIT: I am concerned with low-level representation of transactions and blocks and how they are stored on disk. I understand that they are in RLP format from ethereum wiki. What exactly I am looking for is which files belong to blocks (and transactions) and which don't.

4

1 Answer 1

1

The easiest way is to use the official NodeJS library, write a few lines of JavaScript to scan all of the blocks, and optionally all transactions in each block. Start at block 0 and keep scanning until it returns null.

You can do that with far less code than it would take to read/parse, and it would have the added benefit of never needing an upgrade just because the underlying db changed.

2
  • I am concerned with low-level representation of transactions and blocks and how they are stored on disk. I understand their RLP format from ethereum wiki. Are you suggesting that each ldb file contains both block/transaction information and state information?
    – Ram
    Commented Oct 23, 2016 at 13:30
  • I'm suggesting that there is no reason you need to read the files at all. The API will let you inspect all of the data in a consistent manner whether you use eth, geth or some future sever that uses an entirely different local db schema. Forget there are files. Access the db via the API. Commented Oct 23, 2016 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.