There was a rare case that a block could be incorrectly added to
the indexer if the indexer was disabled during a reorg to a height
that matched the height that was expected, and the `sync` method
for the indexer wasn't called that would detect the reorg.
- Write indexer state and index atomically.
- Simplify chain state with current height.
- Roll forward to best height.
- Synchronize the index with the chain with common method `sync` for
the events 'connect', 'disconnect' and 'reset'. This will prevent
any of the events from conflicting with each other.
- Fix the chain rollback and reset.
- Make sure blocks are connected in the correct order.
- Improve logging to log similar to chain.
module indexer introduces a extensible architecture for indexing the
chain. It provides a base class which handles syncing with the chain,
handling re-orgs, interruptions, dynamic toggling, etc. TXIndexer
and AddrIndexer are provided for indexing transactions and addresses,
using the same flags as before i.e --index-tx and --index-address.
Indexes are stored in a different database and can be maintained
independently of the chain.
This has been patched in both bitcoind and btcd around February 20th, 2014. It was
shortly followed by a headers-first synchronization of blocks.
- d8b4b49667
- 50b6e10b57
- Multiple parallel runs of the same test will not conflict
as a unique identifier is added to the test directory.
- The base test directory can be configured for various
environments, and can be changed via the environment
variable `TEMP`, see the implementation of `os.tmpdir()`
for specific details.
There is potential for around a 10% to 23% increase to the performance
of block reads by using `allocUnsafe`, however there is already around
a 3 to 6 times increase to the performance. While it's safe to use
`allocUnsafe` as the number of bytes read is checked to be the same
size as the buffer allocation, there is a potential for test cases
to introduce _other_ behavior for `fs.read` that may not have the
same behavior, though this isn't currently the case.