Index the blockchain:
    * find the range of blocks
    * synchronize our state engine up to them

    Return True if we should continue indexing
    Return False if not
    Aborts on error

def index_blockchain(server_state, expected_snapshots=GENESIS_SNAPSHOT):
    """
    Index the blockchain:
    * find the range of blocks
    * synchronize our state engine up to them

    Return True if we should continue indexing
    Return False if not
    Aborts on error
    """
    working_dir = server_state['working_dir']
    log.debug("index blockchain in {}".format(working_dir))
    blockstack_opts = get_blockstack_opts()

    bt_opts = get_bitcoin_opts()
    start_block, current_block = get_index_range(working_dir)

    db = get_db_state(working_dir)
    old_lastblock = db.lastblock

    if start_block is None and current_block is None:
        log.error("Failed to find block range")
        db.close()
        return False

    # sanity check: does the subdomain db exist yet, and are we at the point where we can start indexing them?
    if is_subdomains_enabled(blockstack_opts):
        subdomain_last_block = server_state['subdomains'].get_db().get_last_block()
        if subdomain_last_block < SUBDOMAINS_FIRST_BLOCK and start_block >= SUBDOMAINS_FIRST_BLOCK and not server_state['subdomains_initialized']:
            # initialize subdomains db
            log.debug("Creating subdomain DB {}".format(blockstack_opts['subdomaindb_path']))
            server_state['subdomains'].reindex(current_block)
            server_state['subdomains_initialized'] = True

    # bring the db up to the chain tip.
    # NOTE: at each block, the atlas db will be synchronized by virtualchain_hooks
    log.debug("Begin indexing (up to %s)" % current_block)
    set_indexing( working_dir, True )
    rc = virtualchain_hooks.sync_blockchain(working_dir, bt_opts, current_block, server_state, expected_snapshots=expected_snapshots, tx_filter=blockstack_tx_filter)
    set_indexing( working_dir, False )

    db.close()

    if not rc:
        log.debug("Stopped indexing at %s" % current_block)
        return rc

    # uncache state specific to this block
    rpc_chain_sync(server_state, current_block, time.time())

    log.debug("End indexing (up to %s)" % current_block)
    return rc