def _read_varint(raw_hex):
    """
    Reads the weird format of VarInt present in src/serialize.h of raven core
    and being used for storing data in the leveldb.
    This is not the VARINT format described for general ravencoin serialization
    use.
    """
    n = 0
    pos = 0
    while True:
        data = raw_hex[pos]
        pos += 1
        n = n << 7 | data & 127
        if data & 128 == 0:
            return n, pos
        n += 1
