Beispiel #1
0
def block_offset_timeout(
    raiden: RaidenService,
    error_message: Optional[str] = None,
    offset: Optional[BlockOffset] = None,
    safety_margin: int = 5,
) -> BlockTimeout:
    """
    Returns a BlockTimeout that will fire after a number of blocks. Usually created
    at the same time as a set of transfers to wait until their expiration.
    """
    expiration = BlockNumber(raiden.get_block_number() +
                             (offset or raiden.config.settle_timeout) +
                             safety_margin)
    exception = RuntimeError(
        error_message
        or "Events were not completed in the required number of blocks.")
    return BlockTimeout(
        raiden=raiden,
        exception_to_throw=exception,
        block_number=expiration,
        retry_timeout=DEFAULT_RETRY_TIMEOUT,
    )