2.12.ipv8.util

Module Contents

Functions

Attributes

2.12.ipv8.util.maximum_integer = 2147483647
2.12.ipv8.util.int2byte
2.12.ipv8.util.byte2int
2.12.ipv8.util.T
2.12.ipv8.util.succeed(result: T) asyncio.Future[T]

Convert a value to a future with the value set as the result.

2.12.ipv8.util.fail(exception: type | BaseException) asyncio.Future

Return a future with the given exception set as its exception.

2.12.ipv8.util.maybe_coroutine(func: Callable, *args: Any, **kwargs) Awaitable

Ensure the return value of a callable is awaitable.

2.12.ipv8.util.coroutine(func: Callable) Callable[[tuple[Any, Ellipsis], dict[str, Any]], Coroutine[Any, Any, Awaitable]]

Ensure that the given callable is awaitable.

2.12.ipv8.util.strip_sha1_padding(s: bytes) bytes

Strip the artificial SHA-1 prefix to make it the same byte space as SHA3-256.

2.12.ipv8.util.create_event_with_signals(*args: int) asyncio.Event

Creates an event that gets set when certain signals are received. If signals are omitted, the signals SIGINT and SIGTERM will be used. If you don’t need access to the event itself, the use of run_forever is preferred.

Parameters:

args ([int]) – signals after which the event should be set

Return type:

asyncio.Event

2.12.ipv8.util.run_forever() Coroutine

Helper function for waiting until the user presses Ctrl+C. Commonly used for keeping an application alive until shutdown.

Return type:

coroutine