CounterpartyXCP/counterpartyd — pull request #362 by JahPowerBit (2014-10-23 15:48:20+00:00)
Title: Fast initial synchronisation

The synchronisation is done directly from bitcoind database files.
Here the steps of the process:

- step 1: copy bitcoin leveldb database in tmp directory
- step 2: prepare sqlite database
- step 3: parse all blocks backward (the position of each block in blk000XX.dat files, are taken from the leveldb index (blocks/index dir)
- step 4: reorder transactions
- step 5: parse transactions
- step 6: delete bitcoind leveldb database from tmp directory

The main function, where these 6 steps are done, is `blocks.initialise_transactions()`:
https://github.com/JahPowerBit/counterpartyd/blob/develop/lib/blocks.py#L1260

Average time to parse a block on an Intel Xeon 3.2Ghz with a 7200 RPM HD is about 0.1s.

**Important**: bitcoind must be stopped before launching this script.

Missing:
- manage `get_tx_info2`
- add a warning/question "stop your bitcoind, this operations takes times, etc... are you sure you want to continue ? y/n"
- make a python lib for all files in `/lib/blockchain/` installable with pip