macula_routing_server (macula v0.25.1)
View SourceGenServer managing Kademlia DHT routing table and operations. Integrates all routing components: table, DHT algorithms, protocol.
Summary
Functions
Add node to routing table (async - does not block caller).
Delete value from local storage.
Find k closest nodes to target.
Find value in DHT — goes through gen_server for full iterative lookup. For local-only reads (answering peer queries), use find_value_local/2.
Fast local-only lookup via ETS — for answering incoming FIND_VALUE from peers. Does NOT query the network. Returns only locally stored values.
Get all keys from local storage.
Get value from local storage.
Get routing table snapshot.
Handle incoming DHT message and return reply.
Handle incoming DHT message asynchronously (fire-and-forget). Use for STORE messages where no reply is needed.
Remove node from routing table (async - does not block caller).
Get number of nodes in routing table.
Start routing server with registered name macula_routing_server.
Store value in DHT by propagating to k closest nodes. Stores locally first, then sends STORE messages to k closest peers.
Store value locally.
Functions
-spec add_node(pid(), macula_routing_bucket:node_info()) -> ok.
Add node to routing table (async - does not block caller).
Delete value from local storage.
-spec find_closest(pid(), binary(), pos_integer()) -> [macula_routing_bucket:node_info()].
Find k closest nodes to target.
-spec find_value(pid(), binary(), pos_integer()) -> {ok, term()} | {nodes, [macula_routing_bucket:node_info()]} | {error, term()}.
Find value in DHT — goes through gen_server for full iterative lookup. For local-only reads (answering peer queries), use find_value_local/2.
-spec find_value_local(binary(), pos_integer()) -> {ok, term()} | {error, not_found}.
Fast local-only lookup via ETS — for answering incoming FIND_VALUE from peers. Does NOT query the network. Returns only locally stored values.
Get all keys from local storage.
Get value from local storage.
-spec get_routing_table(pid()) -> macula_routing_table:routing_table().
Get routing table snapshot.
Handle incoming DHT message and return reply.
Handle incoming DHT message asynchronously (fire-and-forget). Use for STORE messages where no reply is needed.
Remove node from routing table (async - does not block caller).
-spec size(pid()) -> non_neg_integer().
Get number of nodes in routing table.
Start routing server with registered name macula_routing_server.
Store value in DHT by propagating to k closest nodes. Stores locally first, then sends STORE messages to k closest peers.
Store value locally.