Skip to main content

chord_dht/
rpc.rs

1use crate::core::{
2	ring::Digest,
3	Node,
4	data_store::{Key, Value}
5};
6
7#[tarpc::service]
8pub trait NodeService {
9	// Get fields at this node
10	async fn get_node_rpc() -> Node;
11	async fn get_predecessor_rpc() -> Option<Node>;
12	async fn get_successor_rpc() -> Node;
13	async fn get_successor_list_rpc() -> Vec<Node>;
14
15	// Core functions for Chord
16	async fn find_successor_list_rpc(id: Digest) -> Vec<Node>;
17	async fn find_predecessor_rpc(id: Digest) -> Node;
18	async fn closest_preceding_finger_rpc(id: Digest) -> Node;
19	async fn notify_rpc(node: Node);
20	async fn stabilize_rpc();
21
22	// Get or set key locally
23	async fn get_local_rpc(key: Key) -> Option<Value>;
24	async fn set_local_rpc(key: Key, value: Option<Value>);
25
26	// Get or set key on the ring
27	async fn get_rpc(key: Key) -> Option<Value>;
28	async fn set_rpc(key: Key, value: Option<Value>);
29
30	// Replicate data at this node
31	async fn replicate_rpc(key: Key, value: Option<Value>);
32}