Skip to content

How it works

Ladislau Molnar edited this page Jan 14, 2017 · 13 revisions

BitcoinDatabaseGenerator is a Windows command line tool. Running:
BitcoinDatabaseGenerator /?
will show a help page that has all the information you need to get started.

Here are a few more details about what the tool does during processing. There are two important scenarios:

The first run
On the first run the application detects that the database specified in the command line parameters does not exist and performs the following steps:

  • The Database is created and its schema is setup.
  • Database indexes are disabled to speed up the data transfer.
  • Data is transferred from all the blockchain files to the database. To achieve a high performance for the transfer, data is copied using SQL bulk copy and the copy process is distributed on multiple threads.
  • Database indexes are rebuilt.
  • Stale blocks are detected and deleted from database.
  • Direct links between transaction inputs and their source outputs are calculated and set in the database. This is an important step that can significantly improve the performance of certain SQL queries. For more details see direct links between transaction inputs and outputs.
  • The database files are shrunk.

A subsequent run

In this case an incremental process takes place. The following steps are performed:

  • The tool will detect the last blockchain file that was transferred in the previous session. It will delete from the database all rows that originated from that blockchain file.
  • Data is transferred from all the new blockchain files starting with the one that was determined at the previous step.
  • Stale blocks are detected and deleted from database.
  • Direct links between transaction inputs and their source outputs are calculated and set in the database.
  • The database files are shrunk.

Here is the typical output produced by running the tool in these two scenarios.

Clone this wiki locally