2

I am thinking about the 'science' of block explorers

When I go to a block explorer and view an address, I see a list of transactions in that address and current balance

Is this technically just the contents of each block being stored as they are created (or retroactively parsed) and assigning a database entry for each new element found in that block?

Or even storing every unconfirmed transaction's data as well?

Writing this out, I think I answered my own question, but maybe there is some more efficient or clever thing going on here

3

Yeah, that's how they work. For example, blockexplorer.com gets blocks from Bitcoin Core via JSON-RPC, gathers interesting chunks of data, and puts this data into a SQL database for easy access later. The code for this is only ~300 lines long (though it's very messy). Other block explorers work similarly. In fact, Bitcoin Core itself works something like this, though it uses a key-value database instead of a relational database, and it doesn't store any info about addresses.

  • that database must be huge, for block explorer providers, how do they manage speed/cost for all the unique queries – CQM Jul 17 '14 at 23:30
  • @CQM: A good database has no trouble dealing with a few dozen gigabytes of data. – Greg Hewgill Jul 18 '14 at 1:12
  • @CQM The blockexplorer.com database is ~60 GB, but with proper indexing and carefully-written queries, even huge databases can be queried with decent speed. I originally wrote blockexplorer.com when the Bitcoin block chain was less than a few GBs, though, and it hasn't been updated much since then, so some things are in fact painfully slow nowadays, especially database updates. Other block explorers are more carefully optimized for the large block chain. – theymos Jul 18 '14 at 4:23
0

You can also use the system at http://BlockchainSQL.io to parse the Bitcoin blockchain into an SQL database. It can talk directly to nodes via the protocol and/or parse Core's BLK files.

Disclaimer: I am the developer of that system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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