def nostr_pow_worker(nonce, nostr_pubk, target_bits, hash_function, hash_len_bits, shutdown):
    """Function to generate PoW for Nostr, to be spawned in a ProcessPoolExecutor."""
    hash_preimage = b'electrum-' + nostr_pubk
    while True:
        # we cannot check is_set on each iteration as it has a lot of overhead, this way we can check
        # it with low overhead (just the additional range counter)
        for i in range(1000000):
            digest = hash_function(hash_preimage + nonce.to_bytes(32, 'big')).digest()
            if int.from_bytes(digest, 'big') < (1 << (hash_len_bits - target_bits)):
                shutdown.set()
                return hash, nonce
            nonce += 1
        if shutdown.is_set():
            return None, None
Function to generate PoW for Nostr, to be spawned in a ProcessPoolExecutor.
electrum/util.py