snops_common/rpc/control/
agent.rs1use std::net::IpAddr;
2
3use serde::{Deserialize, Serialize};
4
5use crate::rpc::error::*;
6use crate::state::snarkos_status::SnarkOSLiteBlock;
7use crate::{
8 prelude::EnvId,
9 state::{AgentState, NetworkId, PortConfig},
10};
11
12#[derive(Debug, Clone, Default, Serialize, Deserialize)]
13pub struct Handshake {
14 pub jwt: Option<String>,
15 pub loki: Option<String>,
16 pub state: AgentState,
17}
18
19#[tarpc::service]
21pub trait AgentService {
22 async fn handshake(handshake: Handshake) -> Result<(), ReconcileError>;
24
25 async fn get_addrs() -> (PortConfig, Option<IpAddr>, Vec<IpAddr>);
28
29 async fn reconcile(to: AgentState) -> Result<(), ReconcileError>;
32
33 async fn broadcast_tx(tx: String) -> Result<(), AgentError>;
35
36 async fn snarkos_get(route: String) -> Result<String, SnarkosRequestError>;
38
39 async fn kill();
41
42 async fn execute_authorization(
46 env_id: EnvId,
47 network: NetworkId,
48 query: String,
49 auth: String,
50 ) -> Result<String, AgentError>;
51
52 async fn get_metric(metric: AgentMetric) -> f64;
53
54 async fn set_log_level(level: String) -> Result<(), AgentError>;
55
56 async fn find_transaction(tx_id: String) -> Result<Option<String>, AgentError>;
58
59 async fn get_snarkos_block_lite(
61 block_hash: String,
62 ) -> Result<Option<SnarkOSLiteBlock>, AgentError>;
63
64 async fn set_aot_log_level(verbosity: u8) -> Result<(), AgentError>;
65
66 async fn get_status() -> Result<AgentStatus, AgentError>;
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct AgentStatus {
71 pub aot_online: bool,
72 pub version: String,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub enum AgentMetric {
77 Tps,
78}