Get the atlas zonefile inventory from the given peer.
    offset/count are in bytes.
    Return {'status': True, 'inv': inventory} on success.
    Return {'error': ...} on error

def get_zonefile_inventory(hostport, offset, count, timeout=30, my_hostport=None, proxy=None):
    """
    Get the atlas zonefile inventory from the given peer.
    offset/count are in bytes.
    Return {'status': True, 'inv': inventory} on success.
    Return {'error': ...} on error
    """
    
    assert hostport or proxy, 'Need either hostport or proxy'

    inv_schema = {
        'type': 'object',
        'properties': {
            'inv': {
                'type': 'string',
                'pattern': OP_BASE64_EMPTY_PATTERN
            },
        },
        'required': [
            'inv'
        ]
    }

    schema = json_response_schema( inv_schema )

    if proxy is None:
        proxy = connect_hostport(hostport)

    zf_inv = None
    try:
        zf_inv = proxy.get_zonefile_inventory(offset, count)
        zf_inv = json_validate(schema, zf_inv)
        if json_is_error(zf_inv):
            return zf_inv

        # decode
        zf_inv['inv'] = base64.b64decode(str(zf_inv['inv']))

        # make sure it corresponds to this range
        assert len(zf_inv['inv']) <= count, 'Zonefile inventory in is too long (got {} bytes)'.format(len(zf_inv['inv']))

    except ValidationError as ve:
        if BLOCKSTACK_DEBUG:
            log.exception(ve)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except AssertionError as ae:
        if BLOCKSTACK_DEBUG:
            log.exception(ae)

        resp = {'error': 'Server replied an invalid zone file inventory vector'}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return zf_inv