Set up the atlas node:
    * create the db if it doesn't exist
    * go through all the names and verify that we have the *current* zonefiles
    * if we don't, queue them for fetching.
    * set up the peer db

    @db should be an instance of BlockstackDB
    @initial_peers should be a list of URLs

    Return the newly-initialized peer table

def atlasdb_init( path, zonefile_dir, db, peer_seeds, peer_blacklist, recover=False, validate=False):
    """
    Set up the atlas node:
    * create the db if it doesn't exist
    * go through all the names and verify that we have the *current* zonefiles
    * if we don't, queue them for fetching.
    * set up the peer db

    @db should be an instance of BlockstackDB
    @initial_peers should be a list of URLs

    Return the newly-initialized peer table
    """
    
    global ATLASDB_SQL

    peer_table = {}

    if os.path.exists( path ):
        log.debug("Atlas DB exists at %s" % path)
        
        con = atlasdb_open( path )
        atlasdb_last_block = atlasdb_get_lastblock( con=con, path=path )
        if atlasdb_last_block is None:
            atlasdb_last_block = FIRST_BLOCK_MAINNET

        log.debug("Synchronize zonefiles from %s to %s" % (atlasdb_last_block, db.lastblock) )

        atlasdb_queue_zonefiles( con, db, atlasdb_last_block, zonefile_dir, recover=recover, validate=validate)

        log.debug("Refreshing seed peers")
        for peer in peer_seeds:
            # forcibly add seed peers
            atlasdb_add_peer( peer, con=con, peer_table=peer_table, ping_on_evict=False )

        # re-try fetching zonefiles from storage if we don't have them yet
        atlasdb_reset_zonefile_tried_storage( con=con, path=path )

        # load up peer table from the db
        log.debug("Loading peer table")
        peer_table = atlasdb_load_peer_table( con=con, path=path )

        # cache zonefile inventory and count
        atlasdb_cache_zonefile_info( con=con )
        con.close()

    else:

        log.debug("Initializing Atlas DB at %s" % path)

        lines = [l + ";" for l in ATLASDB_SQL.split(";")]
        con = sqlite3.connect( path, isolation_level=None )

        for line in lines:
            db_query_execute(con, line, ())

        con.row_factory = atlasdb_row_factory

        # populate from db
        log.debug("Queuing all zonefiles")
        atlasdb_queue_zonefiles( con, db, FIRST_BLOCK_MAINNET, zonefile_dir, recover=recover, validate=validate)

        log.debug("Adding seed peers")
        for peer in peer_seeds:
            atlasdb_add_peer( peer, con=con, peer_table=peer_table )

        atlasdb_cache_zonefile_info( con=con )
        con.close()

    log.debug("peer_table: {}".format(peer_table.keys()))

    # whitelist and blacklist
    for peer_url in peer_seeds:
        host, port = url_to_host_port( peer_url )
        peer_hostport = "%s:%s" % (host, port)

        if peer_hostport not in peer_table.keys():
            atlasdb_add_peer( peer_hostport, path=path, peer_table=peer_table )

        log.debug("peer_table: {}".format(peer_table.keys()))
        peer_table[peer_hostport]['whitelisted'] = True

    for peer_url in peer_blacklist:
        host, port = url_to_host_port( peer_url )
        peer_hostport = "%s:%s" % (host, port)

        if peer_hostport not in peer_table.keys():
            atlasdb_add_peer( peer_hostport, path=path, peer_table=peer_table )
        
        log.debug("peer_table: {}".format(peer_table.keys()))
        peer_table[peer_hostport]['blacklisted'] = True

    return peer_table