Get the zonefile inventory from the remote peer
    Start from the given bit_offset

    NOTE: this doesn't update the peer table health by default;
    you'll have to explicitly pass in a peer table (i.e. setting
    to {} ensures that nothing happens).

def atlas_peer_download_zonefile_inventory( my_hostport, peer_hostport, maxlen, bit_offset=0, timeout=None, peer_table={} ):
    """
    Get the zonefile inventory from the remote peer
    Start from the given bit_offset

    NOTE: this doesn't update the peer table health by default;
    you'll have to explicitly pass in a peer table (i.e. setting
    to {} ensures that nothing happens).
    """

    if timeout is None:
        timeout = atlas_inv_timeout()

    interval = 524288       # number of bits in 64KB
    peer_inv = ""

    log.debug("Download zonefile inventory %s-%s from %s" % (bit_offset, maxlen, peer_hostport))

    if bit_offset > maxlen:
        # synced already
        return peer_inv

    for offset in xrange( bit_offset, maxlen, interval):
        next_inv = atlas_peer_get_zonefile_inventory_range( my_hostport, peer_hostport, offset, interval, timeout=timeout, peer_table=peer_table )
        if next_inv is None:
            # partial failure
            log.debug("Failed to sync inventory for %s from %s to %s" % (peer_hostport, offset, offset+interval))
            break

        peer_inv += next_inv
        if len(next_inv) < interval:
            # end-of-interval
            break

    return peer_inv