Get the zonefile inventory bit vector for a given peer.
    The returned range will be [bit_offset, bit_offset+count]

    Update peer health information as well.
    
    bit_offset and bit_count are in bits.

    Return the bit vector on success (padded to the nearest byte with 0's).
    Return None if we couldn't contact the peer.

def atlas_peer_get_zonefile_inventory_range( my_hostport, peer_hostport, bit_offset, bit_count, timeout=None, peer_table=None ):
    """
    Get the zonefile inventory bit vector for a given peer.
    The returned range will be [bit_offset, bit_offset+count]

    Update peer health information as well.
    
    bit_offset and bit_count are in bits.

    Return the bit vector on success (padded to the nearest byte with 0's).
    Return None if we couldn't contact the peer.
    """

    if timeout is None:
        timeout = atlas_inv_timeout()

    zf_inv = {}
    zf_inv_list = None
    
    host, port = url_to_host_port( peer_hostport )
    RPC = get_rpc_client_class()
    rpc = RPC( host, port, timeout=timeout, src=my_hostport )

    assert not atlas_peer_table_is_locked_by_me()

    zf_inv = None

    log.debug("Get zonefile inventory range %s-%s from %s" % (bit_offset, bit_count, peer_hostport))
    try:
        zf_inv = blockstack_get_zonefile_inventory( peer_hostport, bit_offset, bit_count, timeout=timeout, my_hostport=my_hostport, proxy=rpc )
     
    except (socket.timeout, socket.gaierror, socket.herror, socket.error), se:
        atlas_log_socket_error( "get_zonefile_inventory(%s, %s, %s)" % (peer_hostport, bit_offset, bit_count), peer_hostport, se )
        log.error("Failed to ask %s for zonefile inventory over %s-%s (socket-related error)" % (peer_hostport, bit_offset, bit_count))
        
    except Exception, e:
        if os.environ.get("BLOCKSTACK_DEBUG") == "1":
            log.exception(e)

        log.error("Failed to ask %s for zonefile inventory over %s-%s" % (peer_hostport, bit_offset, bit_count))

    atlas_peer_update_health( peer_hostport, (zf_inv is not None and zf_inv.has_key('status') and zf_inv['status']), peer_table=peer_table )

    if zf_inv is None:
        log.error("No inventory given for %s-%s from %s" % (bit_offset, bit_count, peer_hostport))
        return None 

    if 'error' in zf_inv:
        log.error("Failed to get inventory for %s-%s from %s: %s" % (bit_offset, bit_count, peer_hostport, zf_inv['error']))
        return None

    else:
        inv_str = atlas_inventory_to_string(zf_inv['inv'])
        if len(inv_str) > 40:
            inv_str = inv_str[:40] + "..."

        log.debug("Zonefile inventory for %s (%s-%s) is '%s'" % (peer_hostport, bit_offset, bit_count, inv_str))
        return zf_inv['inv']