use std::net::IpAddr;
use serde::{Deserialize, Serialize};
use crate::rpc::error::*;
use crate::state::snarkos_status::SnarkOSLiteBlock;
use crate::{
prelude::EnvId,
state::{AgentState, NetworkId, PortConfig},
};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Handshake {
pub jwt: Option<String>,
pub loki: Option<String>,
pub state: AgentState,
}
#[tarpc::service]
pub trait AgentService {
async fn handshake(handshake: Handshake) -> Result<(), ReconcileError>;
async fn get_addrs() -> (PortConfig, Option<IpAddr>, Vec<IpAddr>);
async fn reconcile(to: AgentState) -> Result<(), ReconcileError>;
async fn broadcast_tx(tx: String) -> Result<(), AgentError>;
async fn snarkos_get(route: String) -> Result<String, SnarkosRequestError>;
async fn kill();
async fn execute_authorization(
env_id: EnvId,
network: NetworkId,
query: String,
auth: String,
) -> Result<String, AgentError>;
async fn get_metric(metric: AgentMetric) -> f64;
async fn set_log_level(level: String) -> Result<(), AgentError>;
async fn find_transaction(tx_id: String) -> Result<Option<String>, AgentError>;
async fn get_snarkos_block_lite(
block_hash: String,
) -> Result<Option<SnarkOSLiteBlock>, AgentError>;
async fn set_aot_log_level(verbosity: u8) -> Result<(), AgentError>;
async fn get_status() -> Result<AgentStatus, AgentError>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentStatus {
pub aot_online: bool,
pub version: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AgentMetric {
Tps,
}