latest.ipv8.util

Module Contents

Functions

succeed(→ asyncio.Future[T])

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

fail(→ asyncio.Future)

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

maybe_coroutine(→ Awaitable)

Ensure the return value of a callable is awaitable.

coroutine(→ Callable[[tuple[Any, Ellipsis], dict[str, ...)

Ensure that the given callable is awaitable.

strip_sha1_padding(→ bytes)

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

create_event_with_signals(→ asyncio.Event)

Creates an event that gets set when certain signals are received. If signals are omitted,

run_forever(→ Coroutine)

Helper function for waiting until the user presses Ctrl+C. Commonly used

Attributes

maximum_integer

int2byte

byte2int

T

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

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

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

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

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

Ensure the return value of a callable is awaitable.

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

Ensure that the given callable is awaitable.

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

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

latest.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

latest.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