2.12.ipv8.dht.community
Module Contents
Classes
Functions
Attributes
- 2.12.ipv8.dht.community.DHTValue
- 2.12.ipv8.dht.community.PING_INTERVAL = 25
- 2.12.ipv8.dht.community.TOKEN_EXPIRATION_TIME = 600
- 2.12.ipv8.dht.community.DHT_ENTRY_STR = 0
- 2.12.ipv8.dht.community.DHT_ENTRY_STR_SIGNED = 1
- 2.12.ipv8.dht.community.MAX_ENTRY_SIZE = 170
- 2.12.ipv8.dht.community.MAX_ENTRY_AGE = 3600
- 2.12.ipv8.dht.community.MAX_CRAWL_NODES = 8
- 2.12.ipv8.dht.community.MAX_CRAWL_REQUESTS = 24
- 2.12.ipv8.dht.community.MAX_CRAWL_TASKS = 4
- 2.12.ipv8.dht.community.MAX_VALUES_IN_STORE = 8
- 2.12.ipv8.dht.community.MAX_VALUES_IN_FIND = 8
- 2.12.ipv8.dht.community.MAX_NODES_IN_FIND = 8
- 2.12.ipv8.dht.community.TARGET_NODES = 8
- async 2.12.ipv8.dht.community.gather_without_errors(*futures: asyncio.Future) list
Gather only the successful results from the given futures.
- class 2.12.ipv8.dht.community.Request(community: DHTCommunity, msg_type: str, node: 2.12.ipv8.dht.routing.Node, params: list | None = None, consume_errors: bool = False, timeout: float = 5.0)
Bases:
2.12.ipv8.requestcache.RandomNumberCache
This request cache keeps track of all outstanding requests within the DHTCommunity.
- class 2.12.ipv8.dht.community.Crawl(target: bytes, routing_table: 2.12.ipv8.dht.routing.RoutingTable, force_nodes: bool = False, offset: int = 0)
Class to manage crawls in the Community, in search of a specific target key.
- class TodoNode
Node that still need to be contacted.
- node_to_contact: 2.12.ipv8.dht.routing.Node
- node_to_puncture: 2.12.ipv8.dht.routing.Node | None
- __iter__() Iterator
Make this dataclass iterable.
- property cache_candidate: 2.12.ipv8.dht.routing.Node | None
Return closest node to the target that did not respond with values.
- property nodes: list[2.12.ipv8.dht.routing.Node]
Get the nodes we have already contacted to retrieve values.
- add_response(sender: 2.12.ipv8.dht.routing.Node, response: dict[str, list[bytes] | list[2.12.ipv8.dht.routing.Node]]) None
Register a response by the given node.
- class 2.12.ipv8.dht.community.DHTCommunity(settings: 2.12.ipv8.community.CommunitySettings)
Bases:
2.12.ipv8.community.Community
Community for storing/finding key-value pairs.
- community_id
- get_serializer() 2.12.ipv8.messaging.serialization.Serializer
Extend our serializer with a node list packer.
- get_available_strategies() dict[str, type[2.12.ipv8.peerdiscovery.discovery.DiscoveryStrategy]]
Extend our available strategies with our maintenance strategy.
- get_address_class(node: 2.12.ipv8.types.Peer) type[2.12.ipv8.types.Address]
Get the class of the given node’s address.
- get_routing_table(node: 2.12.ipv8.types.Peer) 2.12.ipv8.dht.routing.RoutingTable
Get the routing table that the given node belongs to.
- get_storage(node: 2.12.ipv8.dht.routing.Node) 2.12.ipv8.dht.storage.Storage
Get or create a Storage object for the given node.
- get_my_node_id(node: 2.12.ipv8.types.Peer) bytes
Get our own node id to share with the given node.
- get_requesting_node(peer: 2.12.ipv8.types.Peer) 2.12.ipv8.dht.routing.Node | None
Add the given peer to the appropriate routing table and return it or None if it is already blocked.
- introduction_request_callback(peer: 2.12.ipv8.types.Peer, dist: 2.12.ipv8.messaging.payload_headers.GlobalTimeDistributionPayload, payload: 2.12.ipv8.messaging.payload.IntroductionRequestPayload | 2.12.ipv8.messaging.payload.NewIntroductionRequestPayload) None
Call our node discovery logic when an introduction request is received from it.
- introduction_response_callback(peer: 2.12.ipv8.types.Peer, dist: 2.12.ipv8.messaging.payload_headers.GlobalTimeDistributionPayload, payload: 2.12.ipv8.messaging.payload.IntroductionResponsePayload | 2.12.ipv8.messaging.payload.NewIntroductionResponsePayload) None
Call our node discovery logic when an introduction response is received from it.
- on_node_discovered(public_key_bin: bytes, source_address: 2.12.ipv8.types.Address) None
Handler for potentially new nodes.
- ping(node: 2.12.ipv8.dht.routing.Node) asyncio.Future
Send a ping to the given node.
- on_ping_request(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.PingRequestPayload, data: bytes) None
When we receive a ping request through a valid node, send a response.
- on_ping_response(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.PingResponsePayload, data: bytes) None
When receive a response to our ping, update the node’s metrics.
- unserialize_value(value: bytes) tuple[bytes, bytes | None, int] | None
Unserialize data from the given serialized value.
- add_value(key: bytes, value: bytes, storage: 2.12.ipv8.dht.storage.Storage, max_age: float = MAX_ENTRY_AGE) None
Add a serialized value under the given key into a storage.
- async store_value(key: bytes, data: bytes, sign: bool = False) list[2.12.ipv8.dht.routing.Node]
Attempt to store a value at the given key and return the nodes that store it.
- async _store(key: bytes, value: bytes) list[2.12.ipv8.dht.routing.Node]
Attempt to store a serialized value at the given key and return the nodes that store it.
- async store_on_nodes(key: bytes, values: list[bytes], nodes: list[2.12.ipv8.dht.routing.Node]) list[2.12.ipv8.dht.routing.Node]
Store the given values under a given key on the given nodes.
- on_store_request(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.StoreRequestPayload) None
Store or forward the given requested value.
- on_store_response(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.StoreResponsePayload) None
We got confirmation of storage.
- _send_find_request(node: 2.12.ipv8.dht.routing.Node, target: bytes, force_nodes: bool, offset: int = 0) asyncio.Future
- async _contact_node(crawl: Crawl, node: 2.12.ipv8.dht.routing.Node, puncture_node: 2.12.ipv8.dht.routing.Node) None
- async _find(crawl: Crawl, debug: bool = False) list[2.12.ipv8.dht.routing.Node] | list[DHTValue] | tuple[list[DHTValue], Crawl]
- post_process_values(values: list[bytes]) list[DHTValue]
Unpack signed and unsigned values and filter out duplicates.
- async find(target: bytes, force_nodes: bool, offset: int, debug: bool) Sequence[DHTValue] | tuple[Sequence[DHTValue], list[Crawl]] | Sequence[2.12.ipv8.dht.routing.Node]
Get the values belonging to the given target key.
- async find_values(target: bytes, offset: int = 0, debug: bool = False) Sequence[DHTValue] | tuple[Sequence[DHTValue], list[Crawl]]
Find the values belonging to the target key.
- async find_nodes(target: bytes, debug: bool = False) Sequence[2.12.ipv8.dht.routing.Node]
Find the values belonging to the target key.
- on_find_request(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.FindRequestPayload) None
Try to perform a search for the requested target.
- on_find_response(peer: 2.12.ipv8.types.Peer, payload: 2.12.ipv8.dht.payload.FindResponsePayload) None
We got a response for our find requests.
- generate_token(node: 2.12.ipv8.dht.routing.Node) bytes
Generate a token for the given node.
- check_token(node: 2.12.ipv8.dht.routing.Node, token: bytes) bool
Check if the presented token is valid for the given node.