snops_common/rpc/control/
mod.rs

1pub mod agent;
2
3use std::{
4    collections::{HashMap, HashSet},
5    net::IpAddr,
6};
7
8use super::error::ResolveError;
9use crate::{
10    api::EnvInfo,
11    state::{AgentId, EnvId, NodeStatus, TransferStatus, TransferStatusUpdate},
12};
13
14pub const PING_HEADER: &[u8] = b"snops-agent";
15
16#[tarpc::service]
17pub trait ControlService {
18    /// Resolve the addresses of the given agents.
19    async fn resolve_addrs(
20        peers: HashSet<AgentId>,
21    ) -> Result<HashMap<AgentId, IpAddr>, ResolveError>;
22
23    /// Get the environment info for the given environment.
24    async fn get_env_info(env_id: EnvId) -> Option<EnvInfo>;
25
26    /// Emit an agent transfer status update.
27    async fn post_transfer_status(id: u32, status: TransferStatusUpdate);
28
29    /// Emit current agent transfers. Will overwrite old status.
30    async fn post_transfer_statuses(statuses: Vec<(u32, TransferStatus)>);
31
32    /// Emit an agent block status update.
33    async fn post_block_status(
34        height: u32,
35        timestamp: i64,
36        state_root: String,
37        block_hash: String,
38        prev_block_hash: String,
39    );
40
41    /// Emit an agent node status update.
42    async fn post_node_status(update: NodeStatus);
43}