Object.DistributedRegistry (object v0.1.2)
Distributed registry for Objects using Kademlia DHT algorithm.
Provides a decentralized, fault-tolerant registry for object discovery across network boundaries. Implements Kademlia's XOR-based routing with k-buckets for efficient O(log n) lookups.
Features
- Kademlia DHT with 160-bit node IDs
- K-bucket routing table management
- Iterative lookup procedures
- Node liveness checking via PING/PONG
- Automatic republishing of values
- Byzantine fault tolerance mechanisms
- NAT-aware node addressing
Summary
Functions
Adds a peer to the routing table.
Bootstraps the node into the DHT network.
Returns a specification to start this module under a supervisor.
Finds nodes close to a given ID.
Gets the current node's ID.
Looks up an object by ID in the distributed registry.
Registers a local object in the distributed registry.
Starts the distributed registry.
Types
@type node_id() :: <<_::160>>
@type node_info() :: %{ id: node_id(), address: String.t(), port: non_neg_integer(), last_seen: DateTime.t(), rtt: non_neg_integer() | nil, reputation: float() }
@type query_state() :: %{ type: :find_node | :find_value | :store, target: binary(), visited: MapSet.t(), active: MapSet.t(), best_nodes: [node_info()], from: GenServer.from() | nil, start_time: DateTime.t() }
@type routing_table() :: %{ buckets: %{required(non_neg_integer()) => [node_info()]}, self_id: node_id() }
@type state() :: %{ node_id: node_id(), routing_table: routing_table(), storage: %{required(binary()) => stored_value()}, pending_queries: %{required(reference()) => query_state()}, transport: pid(), config: map() }
@type stored_value() :: %{ key: binary(), value: term(), publisher: node_id(), timestamp: DateTime.t(), ttl: non_neg_integer() }
Functions
@spec add_peer(node_id(), String.t(), non_neg_integer()) :: :ok | {:error, term()}
Adds a peer to the routing table.
Parameters
peer_id
: Node ID of the peeraddress
: IP address of the peerport
: Port number of the peer
@spec bootstrap([{String.t(), non_neg_integer()}]) :: :ok | {:error, term()}
Bootstraps the node into the DHT network.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Finds nodes close to a given ID.
@spec get_node_id() :: node_id()
Gets the current node's ID.
Looks up an object by ID in the distributed registry.
Registers a local object in the distributed registry.
Starts the distributed registry.