latest.ipv8.dht.storage

Module Contents

Classes

Value

Class for storing DHT values.

Storage

Class for storing key-value pairs in memory.

class latest.ipv8.dht.storage.Value(id_: bytes, data: bytes, max_age: float, version: int)

Class for storing DHT values.

property age: float

The time (in seconds) since the last update.

property expired: bool

Whether the maximum time since the last update has been reached.

__eq__(other: object) bool

Whether this value equals another given value.

__hash__() int

The hash is always 0, forcing an expensive lookup.

class latest.ipv8.dht.storage.Storage

Class for storing key-value pairs in memory.

put(key: bytes, data: bytes, id_: bytes | None = None, max_age: float = 86400, version: int = 0) None

Store the given data under a certain key.

get(key: bytes, starting_point: int = 0, limit: int | None = None) list[bytes]

Get the values stored at the given key.

items_older_than(min_age: float) list[tuple[bytes, bytes]]

Get all values that have not been updated for the given amount of time (in seconds).

clean() None

Remove all expired items.