def lsn_to_xlogbyte(lsn):
    """Convert a LSN to a integer pointing to an exact byte in the wal stream."""
    # Split by '/' character
    try:
        xlogid, xrecoff = lsn.split('/')
    except AttributeError:
        return 0

    # Convert both from hex to int
    xlogid = int(xlogid, 16)
    xrecoff = int(xrecoff, 16)

    # multiply wal file nr to offset by multiplying with 2**32, and add offset
    # in file to come to absolute int position of lsn and return result
    return xlogid * 2**32 + xrecoff